13
13
# along with this program; if not, write to the Free Software
14
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
WARNING! This script has been deprecated and will go away soon!
18
A script for starting the loggerhead process.
16
"""A script for starting the loggerhead process."""
20
import logging.handlers
23
21
from optparse import OptionParser
28
from bzrlib.plugin import load_plugins
29
from bzrlib.util.configobj.configobj import ConfigObj
26
from configobj import ConfigObj
31
28
from paste import httpserver
32
29
from paste.httpexceptions import make_middleware
35
32
from loggerhead import daemon
36
33
from loggerhead.apps.config import Root
37
from loggerhead.trace import setup_logging
34
from loggerhead.trace import make_handler, setup_logging
38
35
from loggerhead.apps.error import ErrorHandlerApp
42
sys.stderr.write('\n\n')
43
sys.stderr.write('WARNING!!! This script has been deprecated by '
44
'serve-branches, and will be removed in the next '
45
'release. Please migrate to serve-branches and report '
46
'any missing features.\n')
47
sys.stderr.write('\n\n')
49
38
home = os.path.realpath(os.path.dirname(__file__))
50
39
default_pidfile = os.path.join(home, 'loggerhead.pid')
51
40
default_configfile = os.path.join(home, 'loggerhead.conf')
52
41
default_log_folder = os.path.join(home, 'logs')
53
42
parser = OptionParser(usage='usage: %prog [options]', version='%prog')
54
parser.add_option('-f', '--foreground',
55
action='store_true', dest='foreground', default=False,
43
parser.add_option('-f', '--foreground', action='store_true', dest='foreground', default=False,
56
44
help="run in the foreground; don't daemonize")
57
parser.add_option('-C', '--check', action='store_true',
58
dest='check', default=False,
59
help=("only start if not already running (useful for "
61
parser.add_option('-p', '--pidfile', dest="pidfile",
62
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,
63
48
type=str, help="override pidfile location")
64
parser.add_option('-c', '--config-file', dest="configfile",
65
default=default_configfile,
66
type=str, help="override configuration file location")
67
parser.add_option('-L', '--log-folder', dest="log_folder",
68
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,
69
52
type=str, help="override log file directory")
70
53
options, args = parser.parse_args()
86
67
sys.path.insert(0, extra_path)
88
potential_overrides = [('server.socket_port', int),
89
('server.webpath', str),
90
('server.thread_pool', int),
91
('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) ]
92
73
server_port = int(config.get('server.socket_port', 8080))
93
74
nworkers = int(config.get('server.thread_pool', 10))
94
75
server_host = config.get('server.socket_host', '0.0.0.0')
123
104
scheme, netloc, path, blah, blah, blah = urlparse.urlparse(webpath)
125
105
def app(environ, start_response, orig=app):
126
106
environ['SCRIPT_NAME'] = path
127
107
environ['HTTP_HOST'] = netloc
128
environ['wsgi.url_scheme'] = scheme
129
108
return orig(environ, start_response)
134
111
httpserver.serve(
135
112
app, host=server_host, port=server_port,