1
0
Fork 0
forked from s3lph/matemat

Fix SIGINT termination issues

This commit is contained in:
s3lph 2020-02-03 23:39:51 +01:00
parent 18c720fdab
commit 8700023349
3 changed files with 13 additions and 6 deletions

View file

@ -1,11 +1,11 @@
from typing import Any, Dict, Iterable, Union
from bottle import route, static_file, run
import sys
import os.path
import bottle
from matemat.db import MatematDatabase
from matemat.webserver import cron
from matemat.webserver.logger import Logger
from matemat.webserver.config import get_config, parse_config_file
from matemat.webserver.template import init as template_init
@ -59,11 +59,11 @@ def _init(config: Dict[str, Any]):
template_init(config)
@route('/static/<filename:path>')
@bottle.route('/static/<filename:path>')
def serve_static_files(filename: str):
config = get_config()
staticroot = os.path.abspath(config['staticroot'])
return static_file(filename, root=staticroot)
return bottle.static_file(filename, root=staticroot)
def main():
@ -80,8 +80,12 @@ def main():
host: str = config['listen']
port: int = int(str(config['port']))
# noinspection PyUnresolvedReferences
from matemat.webserver.pagelets.receipt_smtp_cron import receipt_smtp_cron
# Start the web server
run(host=host, port=port, debug=True)
bottle.run(host=host, port=port)
# Stop cron
cron.shutdown()
if __name__ == '__main__':

View file

@ -8,6 +8,10 @@ from matemat.webserver import Logger
_CRON_STATIC_EVENT: Event = Event()
def shutdown(*_args, **_kwargs):
_CRON_STATIC_EVENT.set()
class _GlobalEventTimer(Thread):
"""
A timer similar to threading.Timer, except that waits on an externally supplied threading.Event instance,

View file

@ -15,4 +15,3 @@ from .moduser import moduser
from .modproduct import modproduct
from .userbootstrap import userbootstrap
from .statistics import statistics
from .receipt_smtp_cron import receipt_smtp_cron