34
38
from loggerhead.trace import make_handler, setup_logging
35
39
from loggerhead.apps.error import ErrorHandlerApp
43
sys.stderr.write('\n\n')
44
sys.stderr.write('WARNING!!! This script has been deprecated by '
45
'serve-branches, and will be removed in the next '
46
'release. Please migrate to serve-branches and report '
47
'any missing features.\n')
48
sys.stderr.write('\n\n')
38
50
home = os.path.realpath(os.path.dirname(__file__))
39
51
default_pidfile = os.path.join(home, 'loggerhead.pid')
40
52
default_configfile = os.path.join(home, 'loggerhead.conf')
41
53
default_log_folder = os.path.join(home, 'logs')
42
54
parser = OptionParser(usage='usage: %prog [options]', version='%prog')
43
parser.add_option('-f', '--foreground', action='store_true', dest='foreground', default=False,
55
parser.add_option('-f', '--foreground',
56
action='store_true', dest='foreground', default=False,
44
57
help="run in the foreground; don't daemonize")
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,
58
parser.add_option('-C', '--check', action='store_true',
59
dest='check', default=False,
60
help=("only start if not already running (useful for "
62
parser.add_option('-p', '--pidfile', dest="pidfile",
63
default=default_pidfile,
48
64
type=str, help="override pidfile location")
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,
65
parser.add_option('-c', '--config-file', dest="configfile",
66
default=default_configfile,
67
type=str, help="override configuration file location")
68
parser.add_option('-L', '--log-folder', dest="log_folder",
69
default=default_log_folder,
52
70
type=str, help="override log file directory")
53
71
options, args = parser.parse_args()
67
87
sys.path.insert(0, extra_path)
69
potential_overrides = [ ('server.socket_port', int),
70
('server.webpath', str),
71
('server.thread_pool', int),
72
('server.socket_host' ,str) ]
89
potential_overrides = [('server.socket_port', int),
90
('server.webpath', str),
91
('server.thread_pool', int),
92
('server.socket_host', str)]
73
93
server_port = int(config.get('server.socket_port', 8080))
74
94
nworkers = int(config.get('server.thread_pool', 10))
75
95
server_host = config.get('server.socket_host', '0.0.0.0')
104
124
scheme, netloc, path, blah, blah, blah = urlparse.urlparse(webpath)
105
126
def app(environ, start_response, orig=app):
106
127
environ['SCRIPT_NAME'] = path
107
128
environ['HTTP_HOST'] = netloc
129
environ['wsgi.url_scheme'] = scheme
108
130
return orig(environ, start_response)
111
135
httpserver.serve(
112
136
app, host=server_host, port=server_port,