Run As Service?
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!
You can use pm2 or another way to lunch your app as a service, that's external to pkg.
@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.
why not use for example : winsw if in windows?
+1
I was able to do this with nssm without any problems
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?
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)
@sergiodxa how to run pkg binary file with pm2 in ubuntu?
@sergiodxa yeah how ?
@tauqeer81
http://pm2.keymetrics.io/docs/usage/process-management/#binary-code-execution
like this ?
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"...
You can use pm2 for such purpose. If looking for clusters I suggest to use node cluster module instead of rely on pm2
我能够用 nssm 毫无问题地做到这一点
no.you lied..............
many people can't use nssm