From 7cb7253150e5b734d6024d509b0d08719c9a305d Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 15 May 2025 09:23:22 +0200 Subject: [PATCH] Add non-zero exit code to CLI for startup errors. (#553) * Add non-zero exit code to CLI for startup errors. * Add missing attribute to mock server. Fixes #552. --- daphne/cli.py | 2 ++ tests/test_cli.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/daphne/cli.py b/daphne/cli.py index e6e79b2..a5623ad 100755 --- a/daphne/cli.py +++ b/daphne/cli.py @@ -289,3 +289,5 @@ class CommandLineInterface: server_name=args.server_name, ) self.server.run() + if self.server.abort_start: + exit(1) diff --git a/tests/test_cli.py b/tests/test_cli.py index 8368488..59f44e7 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -81,6 +81,8 @@ class TestCLIInterface(TestCase): Mock server object for testing. """ + abort_start = False + def __init__(self, **kwargs): self.init_kwargs = kwargs