Created
February 16, 2012 02:26
-
-
Save shimondoodkin/1841079 to your computer and use it in GitHub Desktop.
Apache prunsrv - run nodejs as windows service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :: to download Procrun binaries and see documentation visit http://commons.apache.org/daemon/procrun.html | |
| :: this file is used to Reinstall a service each time you run it, | |
| :: if you need to uninstall comment out with "::" the install service line | |
| ::detect x86 or x64 | |
| echo off | |
| IF PROCESSOR_ARCHITECTURE EQU "ia64" GOTO IS_ia64 | |
| IF PROCESSOR_ARCHITEW6432 EQU "ia64" GOTO IS_ia64 | |
| IF PROCESSOR_ARCHITECTURE EQU "amd64" GOTO IS_amd64 | |
| IF PROCESSOR_ARCHITEW6432 EQU "amd64" GOTO IS_amd64 | |
| IF DEFINED ProgramFiles(x86) GOTO IS_amd64 | |
| :IS_x86 | |
| set prunsrv=c:\serverPrune\prunsrv.exe | |
| GOTO IS_x64End | |
| :IS_amd64 | |
| set prunsrv=c:\serverPrune\prunsrv_amd64.exe | |
| GOTO IS_x64End | |
| :IS_ia64 | |
| set prunsrv=c:\serverPrune\prunsrv_ia64.exe | |
| ::GOTO IS_x64End | |
| :IS_x64End | |
| echo on | |
| ::end detect x86 or x64 | |
| ::stop service: | |
| net stop nodehello | |
| ::delete service: | |
| %prunsrv% //DS//nodehello | |
| ::install service: | |
| :: ++StartParams is the arguments. arguments are separated with "#" | |
| %prunsrv% //IS//nodehello --DisplayName="nodejs hello" --Startup=auto --Install=%prunsrv% --StartMode=exe --StartImage="C:\\Program Files (x86)\\nodejs\\node.exe" ++StartParams=C:\Personal\NodeTestFiles\hello.js --StdOutput=C:\Personal\NodeTestFiles\hello.out.log --StdError=C:\Personal\NodeTestFiles\hello.err.log | |
| ::start service: | |
| net start nodehello |
Author
see if you can use nssm and pm2
https://harjinderkamboj.wordpress.com/2012/09/06/running-node-as-a-service-using-nssm-2/
there are more modern tools today
https://dzone.com/articles/running-pm2-amp-nodejs-in-production-environments
https://encyclopediaofdaniel.com/blog/nssm-a-node-js-lifesaver/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I use you commands I get an error with id 5.
The service can't be started. Any idea why that may be?