38
34
from loggerhead.trace import make_handler, setup_logging
39
35
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')
50
38
home = os.path.realpath(os.path.dirname(__file__))
51
39
default_pidfile = os.path.join(home, 'loggerhead.pid')
52
40
default_configfile = os.path.join(home, 'loggerhead.conf')
53
41
default_log_folder = os.path.join(home, 'logs')
54
42
parser = OptionParser(usage='usage: %prog [options]', version='%prog')
55
parser.add_option('-f', '--foreground',
56
action='store_true', dest='foreground', default=False,
43
parser.add_option('-f', '--foreground', action='store_true', dest='foreground', default=False,
57
44
help="run in the foreground; don't daemonize")
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,
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,
64
48
type=str, help="override pidfile location")
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,
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,
70
52
type=str, help="override log file directory")
71
53
options, args = parser.parse_args()
87
67
sys.path.insert(0, extra_path)
89
potential_overrides = [('server.socket_port', int),
90
('server.webpath', str),
91
('server.thread_pool', int),
92
('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) ]
93
73
server_port = int(config.get('server.socket_port', 8080))
94
74
nworkers = int(config.get('server.thread_pool', 10))
95
75
server_host = config.get('server.socket_host', '0.0.0.0')
124
104
scheme, netloc, path, blah, blah, blah = urlparse.urlparse(webpath)
126
105
def app(environ, start_response, orig=app):
127
106
environ['SCRIPT_NAME'] = path
128
107
environ['HTTP_HOST'] = netloc
129
environ['wsgi.url_scheme'] = scheme
130
108
return orig(environ, start_response)
135
111
httpserver.serve(
136
112
app, host=server_host, port=server_port,