Skip to content
Snippets Groups Projects
Unverified Commit 642541e2 authored by drebs's avatar drebs
Browse files

[bug] use reactor.stop() to exit when server startup checks fail

Our current use of sys.exit(20) to stop the server when startup checks
fail affects logging in a bad way. This commit uses a system event
trigger to exit with the desired status code when startup checks fail.

Closes: #8996
parent e4d594fc
Branches
Tags
1 merge request!161Fixes for server test fixture and startup
......@@ -21,6 +21,7 @@ import sys
import os
from twisted.application import service, strports
from twisted.internet import reactor
from twisted.web import server
from leap.soledad.common.couch.check import check_schema_versions
......@@ -32,6 +33,12 @@ from leap.soledad.server import get_config
logger = getLogger(__name__)
def _exit(status):
reactor.addSystemEventTrigger(
'after', 'shutdown', sys.exit, status)
reactor.stop()
#
# necessary checks
#
......@@ -39,11 +46,11 @@ logger = getLogger(__name__)
def check_env(local_port, public_port):
if local_port == public_port:
logger.error("LOCAL_SERVICES_PORT and HTTPS_PORT can't be the same!")
sys.exit(20)
_exit(20)
if public_port is None and not os.getenv('DEBUG_SERVER'):
logger.error("HTTPS_PORT env var is required to be set!")
sys.exit(20)
_exit(20)
def check_conf(conf):
......@@ -58,7 +65,7 @@ def check_conf(conf):
** REFUSING TO START. Please double check your configuration. **
"""
logger.error(message % path)
sys.exit(20)
_exit(20)
#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment