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
diff --git a/turbo_hipster/cmd/server.py b/turbo_hipster/cmd/server.py
index 2e4df47..0ca6b0a 100644
--- a/turbo_hipster/cmd/server.py
+++ b/turbo_hipster/cmd/server.py
@@ -30,7 +30,7 @@
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 @@
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 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()