mirror of
https://github.com/django/daphne.git
synced 2025-07-10 08:02:16 +03:00
feature: cd around as needed to import our ASGI application properly
This commit is contained in:
parent
91565d014b
commit
7ef8d12e3c
|
@ -1,5 +1,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentError, Namespace
|
from argparse import ArgumentError, Namespace
|
||||||
|
|
||||||
|
@ -228,11 +229,24 @@ class CommandLineInterface:
|
||||||
elif args.verbosity >= 1:
|
elif args.verbosity >= 1:
|
||||||
access_log_stream = sys.stdout
|
access_log_stream = sys.stdout
|
||||||
|
|
||||||
|
# ----- Custom fork code start -----
|
||||||
|
# default directory on Heroku is /app/, but we want to import the application from within /app/django-root/
|
||||||
|
original_working_dir = os.getcwd()
|
||||||
|
os.chdir("django-root")
|
||||||
|
sys.path.insert(0, os.getcwd())
|
||||||
|
# ----- Custom fork code end -----
|
||||||
|
|
||||||
# Import application
|
# Import application
|
||||||
sys.path.insert(0, ".")
|
# sys.path.insert(0, ".") # Custom fork: commented out this line, moved to below
|
||||||
application = import_by_path(args.application)
|
application = import_by_path(args.application)
|
||||||
application = guarantee_single_callable(application)
|
application = guarantee_single_callable(application)
|
||||||
|
|
||||||
|
# ----- Custom fork code start -----
|
||||||
|
# Change back out of django-root so that everything else runs as daphne expects
|
||||||
|
os.chdir(original_working_dir)
|
||||||
|
sys.path.insert(0, ".")
|
||||||
|
# ----- Custom fork code end -----
|
||||||
|
|
||||||
# Set up port/host bindings
|
# Set up port/host bindings
|
||||||
if not any(
|
if not any(
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user