From 91565d014b2dc06f1032780029ce456ef19daffd Mon Sep 17 00:00:00 2001 From: Ash Plunkett Date: Tue, 21 Mar 2023 10:31:30 +1100 Subject: [PATCH] feature: add support for heroku-buildpack-nginx --- daphne/cli.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/daphne/cli.py b/daphne/cli.py index 7c0c3c9..0c97e23 100755 --- a/daphne/cli.py +++ b/daphne/cli.py @@ -260,6 +260,17 @@ class CommandLineInterface: endpoints = sorted(args.socket_strings + endpoints) # Start the server logger.info("Starting server at {}".format(", ".join(endpoints))) + + # ----- Custom fork code start ----- + # Daphne allows you to pass in ready_callable - but doesn't actually expose it for you to define! + # So this is yet another piece we need in our custom fork. + def ready_callable(): + # touch app-initialized when server is started + # this is so that Heroku acknowledges that the server is up and running + # https://github.com/heroku/heroku-buildpack-nginx/blob/main/bin/start-nginx#L41-L53 + open("/tmp/app-initialized", "w").close() + # ----- Custom fork code end ----- + self.server = self.server_class( application=application, endpoints=endpoints, @@ -281,5 +292,6 @@ class CommandLineInterface: if args.proxy_headers else None, server_name=args.server_name, + ready_callable=ready_callable, # Custom fork: make sure we pass ready_callable through ) self.server.run()