Fix PBR generated binary error

The PBR generated binary 'turbo-hipster' fails to run as the main
method entry point specified now requires a parameter, which PBR
doesn't handle.

This change adds a new entrypoint for PBR, still named main which
will parse the args and create the parameter needed and then called
the the setup_server method.

Change-Id: Ic11f1da0d2f9a615528bd8620ddf30d81a686498
This commit is contained in:
Matthew Oliver 2014-04-09 15:24:32 +10:00
parent 96adb287f8
commit f94977b1ea

View File

@ -30,7 +30,7 @@ from turbo_hipster import worker_server
PID_FILE_MODULE = extras.try_imports(['daemon.pidlockfile', 'daemon.pidfile'])
def main(args):
def setup_server(args):
with open(args.config, 'r') as config_stream:
config = yaml.safe_load(config_stream)
@ -59,7 +59,7 @@ def main(args):
server.shutdown()
if __name__ == '__main__':
def main():
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(__file__), '../')))
parser = argparse.ArgumentParser()
@ -77,6 +77,10 @@ if __name__ == '__main__':
if args.background:
pidfile = PID_FILE_MODULE.TimeoutPIDLockFile(args.pidfile, 10)
with daemon.DaemonContext(pidfile=pidfile):
main(args)
setup_server(args)
else:
main(args)
setup_server(args)
if __name__ == '__main__':
main()