[英]How to run Daphne Server (Django Channels) & workers in the background?
[英]NSSM - Install windows service to run daphne server for django channels
我在 Windows 机器上运行命令,如下所示启动我的服务器,
D:\django_channels> django_channels_env\Scripts\activate
(django_channels_env) D:\django_channels\djanog_project> daphne -e ssl:8000:privateKey=cert\\development.key:certKey=cert\\development.crt --ws-protocol "graphql-ws" --proxy-headers django_project.asgi:application
我正在使用 nssm,将其作为 Windows 服务。
我已将daphne
命令粘贴到文本文件中并另存为.bat
文件。
nsm 配置:
path = C:\Python\Python36\python.exe
Startup directory = D:\Django channels\django_channels_env
Arguments = "D:\Django channels\real_time_table\ws_daphne.bat"
ws_daphne.bat:
daphne -e ssl:8000:privateKey=cert\\development.key:certKey=cert\\development.crt --ws-protocol "graphql-ws" --proxy-headers project_name.asgi:application
错误:
File "D:\Django channels\real_time_table\ws_daphne.bat", line 1
daphne -e ssl:8000:privateKey=cert\\development.key:certKey=cert\\development.crt --ws-protocol "graphql-ws" --proxy-headers real_time_table.asgi:application
^
SyntaxError: invalid syntax
有人可以指导我在虚拟环境中作为 Windows 服务运行daphne
吗?
我们需要运行daphne.exe
,它存在于我们的虚拟环境中。
XXXX.bat 文件:
call "D:\Django\Django channels\django_channels_env\Scripts\daphne.exe" -e ssl:8000:privateKey=cert\\development.key:certKey=cert\\development.crt --ws-protocol "graphql-ws" --proxy-headers real_time_table.asgi:application
nsm 配置:
path = your\path\env\to\bat_folder\XXXX.bat
Startup directory = your\path\env\to\bat_folder
Arguments = leave empty
这样, daphne
现在作为 Windows 服务工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.