NSSM-安装Windows服务以运行Django频道的daphne服务器

问题描述 投票:0回答:1

我如下所示在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文件。

nssm config:

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吗?

python windows service command-line nssm
1个回答
0
投票

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

nssm config:

path = your\path\env\to\bat_folder\XXXX.bat Startup directory = your\path\env\to\bat_folder Arguments = leave empty 至此,daphne现在正在作为Windows服务使用。

© www.soinside.com 2019 - 2024. All rights reserved.