Restart python3 fix, stop and restart python2 working again

pull/806/head
Ozzieisaacs 6 years ago
parent 341dd77b9d
commit 97064db2a4

@ -25,7 +25,7 @@ import signal
import web import web
try: try:
from gevent.pywsgi import WSGIServer from gevent.piwsgi import WSGIServer
from gevent.pool import Pool from gevent.pool import Pool
from gevent import __version__ as geventVersion from gevent import __version__ as geventVersion
gevent_present = True gevent_present = True
@ -37,6 +37,7 @@ except ImportError:
gevent_present = False gevent_present = False
class server: class server:
wsgiserver = None wsgiserver = None
@ -63,6 +64,7 @@ class server:
self.wsgiserver = WSGIServer(('', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args) self.wsgiserver = WSGIServer(('', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
web.py3_gevent_link = self.wsgiserver web.py3_gevent_link = self.wsgiserver
self.wsgiserver.serve_forever() self.wsgiserver.serve_forever()
except SocketError: except SocketError:
try: try:
web.app.logger.info('Unable to listen on \'\', trying on IPv4 only...') web.app.logger.info('Unable to listen on \'\', trying on IPv4 only...')
@ -110,6 +112,9 @@ class server:
web.helper.global_WorkerThread.stop() web.helper.global_WorkerThread.stop()
sys.exit(1) sys.exit(1)
# ToDo: Somehow caused by circular import under python3 refactor
if sys.version_info > (3, 0):
self.restart = web.py3_restart_Typ
if self.restart == True: if self.restart == True:
web.app.logger.info("Performing restart of Calibre-Web") web.app.logger.info("Performing restart of Calibre-Web")
web.helper.global_WorkerThread.stop() web.helper.global_WorkerThread.stop()
@ -126,12 +131,15 @@ class server:
sys.exit(0) sys.exit(0)
def setRestartTyp(self,starttyp): def setRestartTyp(self,starttyp):
self.restart=starttyp self.restart = starttyp
# ToDo: Somehow caused by circular import under python3 refactor
web.py3_restart_Typ = starttyp
def killServer(self, signum, frame): def killServer(self, signum, frame):
self.stopServer() self.stopServer()
def stopServer(self): def stopServer(self):
# ToDo: Somehow caused by circular import under python3 refactor
if sys.version_info > (3, 0): if sys.version_info > (3, 0):
if not self.wsgiserver: if not self.wsgiserver:
if gevent_present: if gevent_present:

@ -216,7 +216,7 @@ class Updater(threading.Thread):
item_path = os.path.join(destination, item[1:]) item_path = os.path.join(destination, item[1:])
if os.path.isdir(item_path): if os.path.isdir(item_path):
logging.getLogger('cps.web').debug("Delete dir " + item_path) logging.getLogger('cps.web').debug("Delete dir " + item_path)
shutil.rmtree(item_path) shutil.rmtree(item_path, ignore_errors=True)
else: else:
try: try:
logging.getLogger('cps.web').debug("Delete file " + item_path) logging.getLogger('cps.web').debug("Delete file " + item_path)
@ -237,7 +237,7 @@ class Updater(threading.Thread):
return False return False
def _stable_version_info(self): def _stable_version_info(self):
return {'version': '0.6.0'} return {'version': '0.6.0'} # Current version
def _nightly_available_updates(self, request_method): def _nightly_available_updates(self, request_method):
tz = datetime.timedelta(seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone) tz = datetime.timedelta(seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone)

@ -132,7 +132,9 @@ except ImportError:
# Global variables # Global variables
current_milli_time = lambda: int(round(time.time() * 1000)) current_milli_time = lambda: int(round(time.time() * 1000))
gdrive_watch_callback_token = 'target=calibreweb-watch_files' gdrive_watch_callback_token = 'target=calibreweb-watch_files'
# ToDo: Somehow caused by circular import under python3 refactor
py3_gevent_link = None py3_gevent_link = None
py3_restart_Typ = False
EXTENSIONS_UPLOAD = {'txt', 'pdf', 'epub', 'mobi', 'azw', 'azw3', 'cbr', 'cbz', 'cbt', 'djvu', 'prc', 'doc', 'docx', EXTENSIONS_UPLOAD = {'txt', 'pdf', 'epub', 'mobi', 'azw', 'azw3', 'cbr', 'cbz', 'cbt', 'djvu', 'prc', 'doc', 'docx',
'fb2', 'html', 'rtf', 'odt'} 'fb2', 'html', 'rtf', 'odt'}
EXTENSIONS_CONVERT = {'pdf', 'epub', 'mobi', 'azw3', 'docx', 'rtf', 'fb2', 'lit', 'lrf', 'txt', 'htmlz'} EXTENSIONS_CONVERT = {'pdf', 'epub', 'mobi', 'azw3', 'docx', 'rtf', 'fb2', 'lit', 'lrf', 'txt', 'htmlz'}

Loading…
Cancel
Save