35
34
from loggerhead.trace import make_handler, setup_logging
36
35
from loggerhead.apps.error import ErrorHandlerApp
40
38
home = os.path.realpath(os.path.dirname(__file__))
41
39
default_pidfile = os.path.join(home, 'loggerhead.pid')
42
40
default_configfile = os.path.join(home, 'loggerhead.conf')
43
41
default_log_folder = os.path.join(home, 'logs')
44
42
parser = OptionParser(usage='usage: %prog [options]', version='%prog')
45
parser.add_option('-f', '--foreground',
46
action='store_true', dest='foreground', default=False,
43
parser.add_option('-f', '--foreground', action='store_true', dest='foreground', default=False,
47
44
help="run in the foreground; don't daemonize")
48
parser.add_option('-C', '--check', action='store_true',
49
dest='check', default=False,
50
help=("only start if not already running (useful for "
52
parser.add_option('-p', '--pidfile', dest="pidfile",
53
default=default_pidfile,
45
parser.add_option('-C', '--check', action='store_true', dest='check', default=False,
46
help="only start if not already running (useful for cron jobs)")
47
parser.add_option('-p', '--pidfile', dest="pidfile", default=default_pidfile,
54
48
type=str, help="override pidfile location")
55
parser.add_option('-c', '--config-file', dest="configfile",
56
default=default_configfile,
57
type=str, help="override configuration file location")
58
parser.add_option('-L', '--log-folder', dest="log_folder",
59
default=default_log_folder,
49
parser.add_option('-c', '--config-file', dest="configfile", default=default_configfile,
50
type=str, help="override configuration file location")
51
parser.add_option('-L', '--log-folder', dest="log_folder", default=default_log_folder,
60
52
type=str, help="override log file directory")
61
53
options, args = parser.parse_args()
77
67
sys.path.insert(0, extra_path)
79
potential_overrides = [('server.socket_port', int),
80
('server.webpath', str),
81
('server.thread_pool', int),
82
('server.socket_host', str)]
69
potential_overrides = [ ('server.socket_port', int),
70
('server.webpath', str),
71
('server.thread_pool', int),
72
('server.socket_host' ,str) ]
83
73
server_port = int(config.get('server.socket_port', 8080))
84
74
nworkers = int(config.get('server.thread_pool', 10))
85
75
server_host = config.get('server.socket_host', '0.0.0.0')
114
104
scheme, netloc, path, blah, blah, blah = urlparse.urlparse(webpath)
116
105
def app(environ, start_response, orig=app):
117
106
environ['SCRIPT_NAME'] = path
118
107
environ['HTTP_HOST'] = netloc
119
environ['wsgi.url_scheme'] = scheme
120
108
return orig(environ, start_response)
125
111
httpserver.serve(
126
112
app, host=server_host, port=server_port,