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
16
"""A script for starting the loggerhead process."""
17
WARNING! This script has been deprecated and will go away soon!
18
A script for starting the loggerhead process.
20
import logging.handlers
21
23
from optparse import OptionParser
26
from configobj import ConfigObj
28
from bzrlib.plugin import load_plugins
29
from bzrlib.util.configobj.configobj import ConfigObj
28
31
from paste import httpserver
29
32
from paste.httpexceptions import make_middleware
32
35
from loggerhead import daemon
33
36
from loggerhead.apps.config import Root
34
from loggerhead.trace import make_handler, setup_logging
37
from loggerhead.trace import setup_logging
35
38
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')
38
49
home = os.path.realpath(os.path.dirname(__file__))
39
50
default_pidfile = os.path.join(home, 'loggerhead.pid')
40
51
default_configfile = os.path.join(home, 'loggerhead.conf')
41
52
default_log_folder = os.path.join(home, 'logs')
42
53
parser = OptionParser(usage='usage: %prog [options]', version='%prog')
43
parser.add_option('-f', '--foreground', action='store_true', dest='foreground', default=False,
54
parser.add_option('-f', '--foreground',
55
action='store_true', dest='foreground', default=False,
44
56
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,
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,
48
63
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,
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,
52
69
type=str, help="override log file directory")
53
70
options, args = parser.parse_args()
67
86
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) ]
88
potential_overrides = [('server.socket_port', int),
89
('server.webpath', str),
90
('server.thread_pool', int),
91
('server.socket_host', str)]
73
92
server_port = int(config.get('server.socket_port', 8080))
74
93
nworkers = int(config.get('server.thread_pool', 10))
75
94
server_host = config.get('server.socket_host', '0.0.0.0')
104
123
scheme, netloc, path, blah, blah, blah = urlparse.urlparse(webpath)
105
125
def app(environ, start_response, orig=app):
106
126
environ['SCRIPT_NAME'] = path
107
127
environ['HTTP_HOST'] = netloc
128
environ['wsgi.url_scheme'] = scheme
108
129
return orig(environ, start_response)
111
134
httpserver.serve(
112
135
app, host=server_host, port=server_port,