|
|
@ -4,6 +4,7 @@ from couchpotato.api import api, NonBlockHandler |
|
|
|
from couchpotato.core.event import fireEventAsync, fireEvent |
|
|
|
from couchpotato.core.helpers.variable import getDataDir, tryInt |
|
|
|
from logging import handlers |
|
|
|
from tornado.httpserver import HTTPServer |
|
|
|
from tornado.web import Application, FallbackHandler |
|
|
|
from tornado.wsgi import WSGIContainer |
|
|
|
from werkzeug.contrib.cache import FileSystemCache |
|
|
@ -210,8 +211,9 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En |
|
|
|
# app.debug = development |
|
|
|
config = { |
|
|
|
'use_reloader': reloader, |
|
|
|
'host': Env.setting('host', default = '0.0.0.0'), |
|
|
|
'port': tryInt(Env.setting('port', default = 5000)) |
|
|
|
'port': tryInt(Env.setting('port', default = 5000)), |
|
|
|
'ssl_cert': Env.setting('ssl_cert', default = None), |
|
|
|
'ssl_key': Env.setting('ssl_key', default = None), |
|
|
|
} |
|
|
|
|
|
|
|
# Static path |
|
|
@ -243,12 +245,20 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En |
|
|
|
debug = config['use_reloader'] |
|
|
|
) |
|
|
|
|
|
|
|
if config['ssl_cert'] and config['ssl_key']: |
|
|
|
server = HTTPServer(application, no_keep_alive = True, ssl_options = { |
|
|
|
"certfile": config['ssl_cert'], |
|
|
|
"keyfile": config['ssl_key'], |
|
|
|
}) |
|
|
|
else: |
|
|
|
server = HTTPServer(application, no_keep_alive = True) |
|
|
|
|
|
|
|
try_restart = True |
|
|
|
restart_tries = 5 |
|
|
|
|
|
|
|
while try_restart: |
|
|
|
try: |
|
|
|
application.listen(config['port'], config['host'], no_keep_alive = True) |
|
|
|
server.listen(config['port']) |
|
|
|
loop.start() |
|
|
|
except Exception, e: |
|
|
|
try: |
|
|
|