NSSM - the Non-Sucking Service Manager
this is for adding an executable with parameters as a windows service.
It can be a python.exe and the python script to be executed, or simply a .net executable
Simply download the NSSM package and extract it. No installation is needed. Just go the folder and run it from command line:
nssm install
Then it will pop up a window form for entering the service details. On the first tab:
the application path is the full path pointing to the python.exe file. e.g. if pointing to a virtual environment then
D:\Dagster\env\Scripts\python.exe
the startup directory, by default is the directory that contains the python.exe from the application path.
however, if the python process needs a specific directory to run from, e.g. under the dagster project folder, then it can be
D:\Dagster\my-project\
The arguments is the python.exe arguments, e.g. if trying to run python.exe -m dagit
then the arguments is:
-m dagit
Give it a service name descriptive and hit 'Install Service'. Done
Once the Install service button is clicked, the service is available in the Windows Services manager, simply click start to start the service.
The Startup Type can be altered, default to automatic
Remove Service
run command line
nssm remove
it pops up a window for entering the service name, then click Ok to remove
SC.EXE
A similar way to create and remove service is using the sc.exe that comes with windows. The nssm is probably calling the same command?
sc.exe create new-service binpath= "xxx.exe param1 param2"
sc.exe delete new-service