Skip to content

Instantly share code, notes, and snippets.

@shimondoodkin
Created February 16, 2012 02:26
Show Gist options
  • Select an option

  • Save shimondoodkin/1841079 to your computer and use it in GitHub Desktop.

Select an option

Save shimondoodkin/1841079 to your computer and use it in GitHub Desktop.
Apache prunsrv - run nodejs as windows service
:: 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
@fabiante

fabiante commented Jul 5, 2019

Copy link
Copy Markdown

When I use you commands I get an error with id 5.
The service can't be started. Any idea why that may be?

@shimondoodkin

shimondoodkin commented Jul 5, 2019

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment