2017-01-29 21:06:08 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2015-08-02 20:59:11 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2016-12-23 09:53:39 +01:00
|
|
|
|
2015-08-02 20:59:11 +02:00
|
|
|
base_path = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
# Insert local directories into path
|
2016-12-23 09:53:39 +01:00
|
|
|
sys.path.insert(0, os.path.join(base_path, 'vendor'))
|
2015-08-02 20:59:11 +02:00
|
|
|
|
|
|
|
from cps import web
|
|
|
|
from tornado.wsgi import WSGIContainer
|
|
|
|
from tornado.httpserver import HTTPServer
|
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
|
2016-12-23 09:53:39 +01:00
|
|
|
if __name__ == '__main__':
|
2017-01-28 20:16:40 +01:00
|
|
|
if web.ub.DEVELOPMENT:
|
|
|
|
web.app.run(host="0.0.0.0", port=web.ub.config.config_port, debug=True)
|
|
|
|
else:
|
|
|
|
http_server = HTTPServer(WSGIContainer(web.app))
|
|
|
|
http_server.listen(web.ub.config.config_port)
|
|
|
|
IOLoop.instance().start()
|
2017-01-22 16:44:37 +01:00
|
|
|
|
2017-02-20 19:52:00 +01:00
|
|
|
if web.helper.global_task == 0:
|
2017-02-21 19:40:22 +01:00
|
|
|
web.app.logger.info("Performing restart of Calibre-web")
|
2017-01-28 20:16:40 +01:00
|
|
|
os.execl(sys.executable, sys.executable, *sys.argv)
|
2016-12-23 09:53:39 +01:00
|
|
|
else:
|
2017-02-21 19:40:22 +01:00
|
|
|
web.app.logger.info("Performing shutdown of Calibre-web")
|
2017-01-28 20:16:40 +01:00
|
|
|
sys.exit(0)
|