簡體   English   中英

NSSM - 安裝 Windows 服務以運行 django 頻道的 daphne 服務器

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM