1
0
mirror of https://github.com/janeczku/calibre-web.git synced 2024-11-26 08:51:05 +02:00
calibre-web/cps.py

38 lines
1.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
base_path = os.path.dirname(os.path.abspath(__file__))
# Insert local directories into path
sys.path.append(base_path)
sys.path.append(os.path.join(base_path, 'cps'))
sys.path.append(os.path.join(base_path, 'vendor'))
from cps import web
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from gevent.wsgi import WSGIServer
if __name__ == '__main__':
if web.ub.DEVELOPMENT:
web.app.run(host="0.0.0.0", port=web.ub.config.config_port, debug=True)
else:
2017-03-16 23:02:49 +02:00
try:
web.app.logger.info('Attempting to start gevent')
web.start_gevent()
except ImportError:
web.app.logger.info('Falling back to Tornado')
http_server = HTTPServer(WSGIContainer(web.app))
http_server.listen(web.ub.config.config_port)
IOLoop.instance().start()
if web.helper.global_task == 0:
2017-02-21 20:40:22 +02:00
web.app.logger.info("Performing restart of Calibre-web")
os.execl(sys.executable, sys.executable, *sys.argv)
else:
2017-02-21 20:40:22 +02:00
web.app.logger.info("Performing shutdown of Calibre-web")
sys.exit(0)