1
# Copyright 2005 Canonical Ltd. All rights reserved.
3
# NOTE: This code was taken out of runlaunchpad.py. It was used to start the
4
# trebuchet daemon, however this daemon has been superseded by the generic
5
# Launchpad xmlrpc server. -- David Allouche 2006-09-25
14
def start_trebuchet():
15
# Imported here as path is not set fully on module load
16
from canonical.config import config
17
from canonical.pidfile import make_pidfile, pidfile_path
19
# Don't run the Trebuchet if it wasn't asked for.
20
if not config.trebuchet.server.launch:
23
if not os.path.isdir(config.trebuchet.server.root):
24
os.makedirs(config.trebuchet.server.root, 0700)
26
pidfile = pidfile_path('trebuchet')
27
logfile = config.trebuchet.server.logfile
28
tacfile = os.path.abspath(os.path.join(
29
os.path.dirname(__file__), 'daemons', 'trebuchet.tac'
32
ver = '%d.%d' % sys.version_info[:2]
39
"--prefix", "Trebuchet",
43
if config.trebuchet.server.spew:
46
trebuchet_process = subprocess.Popen(args, stdin=subprocess.PIPE)
47
trebuchet_process.stdin.close()
48
# I've left this off - we still check at termination and we can
49
# avoid the startup delay. -- StuartBishop 20050525
51
#if trebuchet_process.poll() != None:
53
# "Trebuchet did not start: %d" % trebuchet_process.returncode
56
if trebuchet_process.poll() is None:
57
os.kill(trebuchet_process.pid, signal.SIGTERM)
58
trebuchet_process.wait()
60
print >> sys.stderr, "*** ERROR: Trebuchet died prematurely!"
61
print >> sys.stderr, "*** Return code was %d" % (
62
trebuchet_process.returncode,
64
atexit.register(stop_trebuchet)