Running socketcluster using pm2 or forever keep display blank node.exe cmd
Hi I'm and my team try to develop an app using socketcluster and now want to deploy it using pm2 at begin
But when we try to deploy it using pm2 and latter I try to use forever it seem it faced same issue
Step to reproduce Install latest socket cluster version using npm Create new project or using code from master branch Try to run sample project using pm2(or forever) forever start --killSignal=SIGTERM server.js -w 2 -s 2 pm2 start server.js
Image 1: start using forever

Image 2: Same issue happen

Image 3: start using pm2

I'm running win 10 Node v8.11.1
Is there any that I doing wrong, is there a way to work around it ? Or this is an issue
@bebeo92 I haven't tried running PM2 on windows with child processes so I'm not sure what is the expected behavior but this does look strange. Do the blank windows close when you kill the main process with PM2?
@jondubois Yes, if I kill main process, it will turn off that child process But you know, when you deploy it into production, you should find a way to run it in background and that it nothing else (no blank screen....). And in my case, our team using pm2, Imagine like you have hundred app running on server and each app need a console to display... it will be a mess right?
So my expectation is find out a way to deploy app using socketcluster using script and it will running silently in background. Is there a way to do it using pm2 or other tool I would like to know, or directly using socketcluster by itself?
@bebeo92 it definitely doesn't do it on Linux (which is the most common production environment). Maybe PM2 is not optimized for Windows.
SC just uses node.js's cluster and child_process modules to spawn up child processes so it's not doing anything out of the ordinary. Have you tried using a different console in Windows? Maybe Powershell?
In any case, it seems to be a PM2 issue: https://github.com/Unitech/pm2/issues/2182
@jondubois Ok then so is there any easy way to start and stop SC automatically? Sorry but I stick with window ....
Oh forget to update, same issue when use powers hell .....
@bebeo92 Maybe try upgrading your PM2 version.
Otherwise, if you think that this issue can be solved inside SC, you can try playing around with the arguments that SC passes to the fork function:
- In main
socketclustermodule: https://github.com/SocketCluster/socketcluster/blob/master/scworkercluster.js#L167 - In
sc-brokerdependency: https://github.com/SocketCluster/sc-broker/blob/master/index.js#L82
Then feel free to make PRs.
@jondubois pm2 already in latest version ...
Option 2 look promise then