我如下所示在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
吗?
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服务使用。