#!/usr/bin/env python
from panoramix import app, config
from subprocess import Popen


if __name__ == "__main__":
    if config.DEBUG:
        app.run(
            host='0.0.0.0',
            port=int(config.PANORAMIX_WEBSERVER_PORT),
            debug=True)
    else:
        cmd = (
            "gunicorn "
            "-w 8 "
            "-b 0.0.0.0:{config.PANORAMIX_WEBSERVER_PORT} "
            "panoramix:app").format(**locals())
        print("Starting server with command: " + cmd)
        Popen(cmd, shell=True).wait()
