~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to start-loggerhead.py

  • Committer: Michael Hudson
  • Date: 2008-06-19 01:18:01 UTC
  • mto: This revision was merged to the branch mainline in revision 164.
  • Revision ID: michael.hudson@canonical.com-20080619011801-fwnrw5ntwnz7q3cu
testingĀ isĀ grate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
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.
6
 
#
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.
11
 
#
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
15
 
 
16
 
"""A script for starting the loggerhead process."""
17
 
 
 
1
#!/usr/bin/env python2.4
18
2
 
19
3
import logging
20
 
import logging.handlers
21
 
from optparse import OptionParser
22
4
import os
23
5
import sys
24
 
import urlparse
25
 
 
26
 
from configobj import ConfigObj
27
 
 
 
6
from optparse import OptionParser
 
7
 
 
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
31
12
 
32
13
from loggerhead import daemon, release
33
 
from loggerhead.apps.config import Root
34
14
 
35
15
 
36
16
def make_handler(config, filename):
66
46
    access_log.setLevel(logging.INFO)
67
47
    access_log.setFormatter(f)
68
48
 
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)
72
52
 
73
53
    if foreground:
74
54
        logging.getLogger('').addHandler(stdout_log)
96
76
 
97
77
    # read loggerhead config
98
78
 
 
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)
101
82
    if extra_path:
138
119
    app = make_filter(app, None)
139
120
 
140
121
    if webpath:
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('/'):
 
123
            webpath += '/'
 
124
        def app(environ, start_response, app=app):
 
125
            environ['SCRIPT_NAME'] = webpath
 
126
            return app(environ, start_response)
146
127
 
147
128
    try:
148
129
        httpserver.serve(