1

I run the commands on a windows machine as shown below to start my server,

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

I'm using nssm, to make this as windows service.

I have pasted, daphne command in a text file and saved as .bat file.

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

Error:

  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

Can someone please guide me to run daphne in a virtual environment as windows service?

shaik moeed
  • 5,300
  • 1
  • 18
  • 54

1 Answers1

0

We need to run daphne.exe, which exists in our virtual environment.

XXXX.bat file:

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

By this, daphne is now working as a windows service.

shaik moeed
  • 5,300
  • 1
  • 18
  • 54