![](/img/trans.png)
[英]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.