pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Run As Service?

Open ethan-gallant opened this issue 9 years ago • 13 comments

Is there any way for me to make the app run as a service? I don't like the command prompt window open while the app is running. Thanks!

ethan-gallant avatar Jun 15 '17 21:06 ethan-gallant

You can use pm2 or another way to lunch your app as a service, that's external to pkg.

sergiodxa avatar Jun 15 '17 21:06 sergiodxa

@sergiodxa This is ideal for what I want to accomplish. I am trying to make a client-side app that runs as a service. All i need to do is daemonize the process.

ethan-gallant avatar Jun 15 '17 22:06 ethan-gallant

why not use for example : winsw if in windows?

ghost avatar Jun 16 '17 08:06 ghost

+1

thbl avatar Jun 27 '17 12:06 thbl

I was able to do this with nssm without any problems

peterbabic avatar Jul 07 '17 12:07 peterbabic

I am using nssm as well, but am getting an issue when attempting to Stop the service. It times out and I have to kill the task from Windows Task Manager. @peterbabic - have you had similar issue?

slmmm avatar Jul 07 '17 15:07 slmmm

I have been using WinSW to wrap my .exe with no issues. Using Wix I have been had been able to script the install of the service

<CustomAction Id="StartMonitorServer" Directory="SERVER" ExeCommand="[SystemFolder]cmd.exe /c my-server.exe install" Execute="immediate" Return="ignore" Impersonate="yes" />

Most of the issues with stopping and starting my services have been down to either port in use errors (which WinSW logs out very nicely) and lack of Administrator privileges (which is the same old Windows malarky)

anvilation avatar Jul 10 '17 11:07 anvilation

@sergiodxa how to run pkg binary file with pm2 in ubuntu?

tauqeer81 avatar Aug 03 '17 15:08 tauqeer81

@sergiodxa yeah how ?

crapthings avatar Dec 05 '17 01:12 crapthings

@tauqeer81

http://pm2.keymetrics.io/docs/usage/process-management/#binary-code-execution

like this ?

crapthings avatar Dec 05 '17 02:12 crapthings

As @crapthings points out, pm2 can handle binary code execution, and I've checked that the following does work (Windows): pm2 start myzeitpkgapp.exe

However, cluster mode doesn't appear to work this way. For example, the following should start four processes/instances, but only starts one: pm2 start myzeitpkgapp.exe -i 4

If that one process goes down, pm2 successfully brings it back up, but it never kicks off 4 processes. I'm probably misunderstanding something, but is it possible to package the pm2 logic within the Zeit PKG executable? Then, executing myzeitpkgapp.exe would essentially call "pm2 start ./main.js -i 4"...

ataft avatar Mar 13 '18 18:03 ataft

You can use pm2 for such purpose. If looking for clusters I suggest to use node cluster module instead of rely on pm2

robertsLando avatar Mar 23 '21 17:03 robertsLando

我能够用 nssm 毫无问题地做到这一点

no.you lied..............

many people can't use nssm

introspection3 avatar Nov 03 '23 02:11 introspection3