2
# This program is free software; you can redistribute it and/or modify
3
# it under the terms of the GNU General Public License as published by
4
# the Free Software Foundation; either version 2 of the License, or
5
# (at your option) any later version.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
"""A script for starting the loggerhead process."""
1
#!/usr/bin/env python2.4
20
import logging.handlers
21
from optparse import OptionParser
26
from configobj import ConfigObj
6
from optparse import OptionParser
8
from loggerhead.apps.config import Root
28
9
from paste import httpserver
29
10
from paste.httpexceptions import make_middleware
30
11
from paste.translogger import make_filter
32
13
from loggerhead import daemon, release
33
from loggerhead.apps.config import Root
36
16
def make_handler(config, filename):
66
46
access_log.setLevel(logging.INFO)
67
47
access_log.setFormatter(f)
69
logging.getLogger('').setLevel(logging.DEBUG)
70
49
logging.getLogger('').addHandler(debug_log)
71
logging.getLogger('wsgi').addHandler(access_log)
50
logging.getLogger('turbogears.access').addHandler(access_log)
51
logging.getLogger('turbogears.controllers').setLevel(logging.INFO)
74
54
logging.getLogger('').addHandler(stdout_log)
97
77
# read loggerhead config
79
from configobj import ConfigObj
99
80
config = ConfigObj(os.path.join(home, 'loggerhead.conf'), encoding='utf-8')
100
81
extra_path = config.get('bzrpath', None)
138
119
app = make_filter(app, None)
141
scheme, netloc, path, blah, blah, blah = urlparse.urlparse(webpath)
142
def app(environ, start_response, orig=app):
143
environ['SCRIPT_NAME'] = path
144
environ['HTTP_HOST'] = netloc
145
return orig(environ, start_response)
122
if not webpath.endswith('/'):
124
def app(environ, start_response, app=app):
125
environ['SCRIPT_NAME'] = webpath
126
return app(environ, start_response)
148
129
httpserver.serve(