Cleanup crash messages. Handle quiet exceptions quietly. Don't re-raise because that would print the traceback twice.
This commit is contained in:
parent
47215d4635
commit
b9b54a2eda
|
@ -49,7 +49,7 @@ from sanic.application.motd import MOTD
|
||||||
from sanic.application.state import ApplicationServerInfo, Mode, ServerStage
|
from sanic.application.state import ApplicationServerInfo, Mode, ServerStage
|
||||||
from sanic.base.meta import SanicMeta
|
from sanic.base.meta import SanicMeta
|
||||||
from sanic.compat import OS_IS_WINDOWS, StartMethod
|
from sanic.compat import OS_IS_WINDOWS, StartMethod
|
||||||
from sanic.exceptions import ServerKilled
|
from sanic.exceptions import SanicException, ServerKilled
|
||||||
from sanic.helpers import Default, _default, is_atty
|
from sanic.helpers import Default, _default, is_atty
|
||||||
from sanic.http.constants import HTTP
|
from sanic.http.constants import HTTP
|
||||||
from sanic.http.tls import get_ssl_context, process_to_context
|
from sanic.http.tls import get_ssl_context, process_to_context
|
||||||
|
@ -880,12 +880,17 @@ class StartupMixin(metaclass=SanicMeta):
|
||||||
manager.run()
|
manager.run()
|
||||||
except ServerKilled:
|
except ServerKilled:
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
|
except SanicException as e:
|
||||||
|
kwargs = {}
|
||||||
|
if e.quiet:
|
||||||
|
error_logger.error(str(e))
|
||||||
|
else:
|
||||||
|
raise
|
||||||
except BaseException:
|
except BaseException:
|
||||||
kwargs = primary_server_info.settings
|
kwargs = primary_server_info.settings
|
||||||
error_logger.exception(
|
error_logger.exception(
|
||||||
"Experienced exception while trying to serve"
|
"Experienced exception while trying to serve"
|
||||||
)
|
)
|
||||||
raise
|
|
||||||
finally:
|
finally:
|
||||||
logger.info("Server Stopped")
|
logger.info("Server Stopped")
|
||||||
for app in apps:
|
for app in apps:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user