-
-
Notifications
You must be signed in to change notification settings - Fork 5
Run as a Windows Service with NSSM
These are user-provided instructions, and I have not validated them. In theory you can just do this as a normal Windows Service, but I know that dealing with Windows Services is not Trivial.
Download NSSM from the official website. NSSM is used to create a windows service to run the script.
Once downloaded, copy nssm.exe to the same directory the script is located in.
Next, open cmd in that directory with administrator privileges.
In cmd, enter the following command:
nssm install AniSync
You can replace AniSync with a name of your choice but remember to replace any instances of AniSync in the following commands with your choice.
Next, enter the following command:
nssm edit AniSync
This will open up a GUI interface. Enter the details as follows:
- Path:
path\to\your\python.exe - Startup Directory:
path\to\your\EmbyAniSync\directory - Arguments:
"path\to\EmbyAniSync.py"

Note:
- Path to your Startup Directory is the same directory where
EmbyAniSync.pyis located. - Arguments should include the quotation marks ("").
Next click on the details tab and make sure Startup type is set to Automatic.

Next, click on Edit Service.
Finally, enter the following command in cmd:
nssm restart AniSync
You can create logs for the service. This can be helpful to debug any issues.
First create a directory to save your log files. Ideally you can create this directory in the same directory as your script.
.
└── EmbyAniSync/
├── embypython/
├── logs/
├── EmbyAniSync.py
└── nssm.exe
Next, open up cmd as administrator in the same directory that EmbyAniSync.py is located.
Enter the following command:
nssm edit AniSync
Now, in the NSSM GUI, click on the I/O tab. You may need to click on the arrow buttons to navigate to it.
-
In
Output (stdout)enter the following:path\to\the\log\directory\service.log -
In
Error (stderr)enter the following:path\to\the\log\directory\service-debug.log

Next, click on Edit Service.
Finally, enter the following command in cmd:
nssm restart AniSync