~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to start-loggerhead.py

  • Committer: Michael Hudson
  • Date: 2008-06-18 07:32:51 UTC
  • mto: This revision was merged to the branch mainline in revision 164.
  • Revision ID: michael.hudson@canonical.com-20080618073251-4hwegw6jm1u7w8p1
so that was all quite broken

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
 
1
#!/usr/bin/env python2.4
2
2
 
3
3
import logging
4
 
import logging.handlers
5
4
import os
6
5
import sys
7
6
from optparse import OptionParser
8
7
 
9
 
from configobj import ConfigObj
10
 
 
 
8
from loggerhead.apps.config import Root
11
9
from paste import httpserver
12
10
from paste.httpexceptions import make_middleware
13
11
from paste.translogger import make_filter
14
12
 
15
13
from loggerhead import daemon, release
16
 
from loggerhead.apps.config import Root
17
14
 
18
15
 
19
16
def make_handler(config, filename):
79
76
 
80
77
    # read loggerhead config
81
78
 
 
79
    from configobj import ConfigObj
82
80
    config = ConfigObj(os.path.join(home, 'loggerhead.conf'), encoding='utf-8')
83
81
    extra_path = config.get('bzrpath', None)
84
82
    if extra_path:
90
88
                            ('server.webpath', str),
91
89
                            ('server.thread_pool', int),
92
90
                            ('server.socket_host' ,str) ]
93
 
    server_port = int(config.get('server.socket_port', 8080))
94
 
    nworkers = int(config.get('server.thread_pool', 10))
95
 
    server_host = config.get('server.socket_host', '0.0.0.0')
96
 
    webpath = config.get('server.webpath', None)
97
 
 
98
91
    for key, keytype in potential_overrides:
99
92
        value = config.get(key, None)
100
93
        if value is not None:
120
113
    app = make_middleware(app)
121
114
    app = make_filter(app, None)
122
115
 
123
 
    if webpath:
124
 
        if not webpath.endswith('/'):
125
 
            webpath += '/'
126
 
        def app(environ, start_response, app=app):
127
 
            environ['SCRIPT_NAME'] = webpath
128
 
            return app(environ, start_response)
129
 
 
130
 
    try:
131
 
        httpserver.serve(
132
 
            app, host=server_host, port=server_port,
133
 
            threadpool_workers=nworkers)
134
 
    finally:
135
 
        log.info('Shutdown.')
136
 
        try:
137
 
            os.remove(pidfile)
138
 
        except OSError:
139
 
            pass
 
116
    httpserver.serve(app, host='127.0.0.1', port='9876')
140
117
 
141
118
 
142
119
if __name__ == '__main__':