我正在尝试使用主管来管理 AWS 中的 Django 应用程序的 Daphne 服务器和一些工作人员。我一直在关注本教程。我的supervisord.conf
样子是这样的:
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0770 ; socket file mode (default 0700)
chown=root:supervisor
[inet_http_server]
port = 9001
username = nte_user # Basic auth username
password = generated-passphrase # Basic auth password
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf
我的自定义配置文件位于并且看起来像这样(我在添加工人之前/etc/supervisor/conf.d/company_name.conf
试图让工作):server_interface
[program:server_interface]
command=/home/web/venv/bin/daphne -b 127.0.0.1 -p 8000 company_name.asgi:channel_layer
directory=/home/web/api-server/company_name/
autostart=true
autorestart=true
stopasgroup=true
user=web
当我运行此命令时:/home/web/venv/bin/daphne -b 127.0.0.1 -p 8000 company_name.asgi:channel_layer
从命令行 while in /home/web/api-server/company_name/
,它工作正常并且服务器启动。当我运行时supervisorctl start server_interface
,我在 sdterr 日志中看到以下输出:
2017-07-07 15:46:06,562 INFO Starting new HTTP connection (1): 169.254.169.254
Traceback (most recent call last):
File "/home/web/venv/bin/daphne", line 11, in <module>
sys.exit(CommandLineInterface.entrypoint())
File "/home/web/venv/local/lib/python2.7/site-packages/daphne/cli.py", line 125, in entrypoint
cls().run(sys.argv[1:])
File "/home/web/venv/local/lib/python2.7/site-packages/daphne/cli.py", line 155, in run
channel_layer = importlib.import_module(module_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "./next-tier/asgi.py", line 6, in <module>
channel_layer = get_channel_layer()
File "/home/web/venv/local/lib/python2.7/site-packages/channels/asgi.py", line 98, in get_channel_layer
django.setup(set_prefix=False)
File "/home/web/venv/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/web/venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/web/venv/local/lib/python2.7/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "./stakeholder/models.py", line 18, in <module>
from .managers import StakeholderManager, ContactInformationManager
File "./stakeholder/managers.py", line 27, in <module>
SURVEY_TABLE = DYNAMO_DB.Table(settings.SURVEY_TABLE_NAME)
File "/home/web/venv/local/lib/python2.7/site-packages/boto3/resources/factory.py", line 474, in create_resource
client=self.meta.client)(*args, **kwargs)
File "/home/web/venv/local/lib/python2.7/site-packages/boto3/dynamodb/transform.py", line 32, in __init__
super(DynamoDBHighLevelResource, self).__init__(*args, **kwargs)
File "/home/web/venv/local/lib/python2.7/site-packages/boto3/dynamodb/table.py", line 30, in __init__
super(TableResource, self).__init__(*args, **kwargs)
File "/home/web/venv/local/lib/python2.7/site-packages/boto3/resources/base.py", line 119, in __init__
'Required parameter {0} not set'.format(identifier))
ValueError: Required parameter name not set
运行printenv
显示设置的必要环境变量,这可以从 Daphne 从命令行正常启动的事实得到证实,但我无法弄清楚为什么它在通过 Supervisor 运行时无法正确启动。