-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node 0.10.x - Port still in use after a "pm2 stop :id" #74
Comments
I tried with node v0.8.17 and v0.11.2, everything is okay, the port is freed when a process is stopped. The command to stop a process managed by pm2 is Which node version do you use ? Thanks |
my mistake, It's was about pm2 stop ;) and not kill. |
I confirm there is a bug with node v0.10.x the port is not freed when stopping the process with |
We've seen this issue even with node 0.8 but can't consistently reproduce it. If I do, I'll report it. What would be the suggested logs/trace that you'd need so I can get them if I run into this bug again. |
Having the same issue with 0.10.. I had to make my git push hook kill and start the pm2 daemon |
It happens everytime for me, I'm still on node 0.8.25. |
@Unitech http://nodejs.org states: Current Version: v0.10.19 |
i haven't found any solution to fix that. I tried 4 differents ways and nothing work with 0.10.x... The only solution will be in the next pm2 version, who include "fork mode", it will not wrap the code anymore and the cluster feature will be disabled :( Hope everyone will switch to 0.11.x or that the 1.x node version will have the same engine for cluster than 0.11.x |
At least one solution would be to clone cluster.js from v0.11.x source code and use it in v0.10.x (the same way as people use streams2 in v0.10.x with readable-stream fallback for v0.8.x). It would be a pain to maintain it though, so it's easier for people to just switch to v0.11.x, it's only a few months from being stable anyway. |
does pm2 play nicely with nvm? can i use node v0.11.x to run pm2 but make it still use node v0.10.x for running scripts i want to manage with it? |
You can get this to happen when you shut down node improperly. Its a node Matej Kramny On 12 Oct 2013, at 01:28 pm, "☮ elf Pavlik ☮" [email protected] does pm2 play nicely with nvm? can i use node v0.11.x to run pm2 but make it still use node v0.10.x for — |
@matejkramny I tried shut down process in different ways (disconnecting, suicide, kill...) nothing works, the port is still not freed. @rlidwka you think it's possible ? I'm scarred that all this mechanism comes from C++ modules and not the cluster.js, I will have a look at it @elf-pavlik as the "cluster mode" require your code, you can't use different node version |
cluster.js doesn't even require any native modules, but base around |
@rlidwka I tried to use the Node v0.11x cluster module for 0.10.x, without success For Node v0.10.x the workaround is now to launch your script in "fork mode" by adding the
I've added a section "known bugs" in the README.md : https://github.com/Unitech/pm2#known-bugs Thanks for reporting, closing |
Did you ever report this to joyent/node? Do you have a simple reproduction? Below doesn't cause any listen socket leak. var cluster = require('cluster')
var net = require('net');
if(cluster.isMaster) {
cluster.fork()
cluster.on('exit', function() {
setTimeout(function() {
cluster.fork();
}, 1000)
})
} else {
var port = Math.floor(Math.random() * 14000 + 2000)
var server = net.createServer()
.listen(port, function() {
console.log('pid %d listen on:', process.pid, port);
process.nextTick(function() {
process.disconnect()
})
})
.on('error', function(er) {
console.log('listen error:', er)
})
} |
There's no reason to, they'll probably not fix this on stable. Why waste time, 0.10.x is almost in maintenance only mode.
Instead of |
v0.8 is still pretty used, v0.10 is going to be around a bit. Whether it is fixed or not probably depends on how hard it is to fix, and how much it hurts users. Anyhow, @Unitech, depending on how |
You can call I'm doing it quite often when I forget the difference between "stop" and "kill" :) |
What is the resolution / workaround for this? It's still occurring for me on |
Is it the same issue when you kill a node app with ctrl-z? Matej Kramny On 22 Jan 2014, at 04:48 pm, Eric Martindale [email protected] What is the resolution / workaround for this? It's still occurring for me — |
|
Oh. Hmm. I could solve this by visiting the url (which strangely still sent some of Matej Kramny On 22 Jan 2014, at 04:59 pm, Eric Martindale [email protected] ^Z should pause an app, not kill -- the port should remain in use in this — |
So how do I solve this? Upgrade node to 0.11.2? |
are you sure it's still the same process ? can you have lock at the pid and confirm ? |
it still happen..how to solve it? |
@goldalworming , update to node 0.11.x? |
in nodejs.org Current Version: v0.10.31 |
gracefulStop (not available) that sends a Btw currently the solutions are:
|
I experience the same issue and I am running in fork mode on node 0.10.31. Can you elaborate on that, @Unitech ? |
@Unitech So my understanding is that for a project that isn't using a web server, cluster mode on node 0.10 is still ok, am I correct? I use pm2 to manage a pool of workers, and I get the warning about fork mode, but everything is working fine. Maybe that warning should only be presented when pm2 manages a listening socket for the managed processes? |
I use node version 0.10.26. Installed pm2 latest version 0.10.7. Port was not getting freed up. uninstalled pm2 and went back to 0.9.4. Works fine now. |
I'm sure that it's [email protected]'s problem. The [email protected] works fine. On [email protected] later, |
Same problem with pm2 0.12.10 pm2 is not killing process if the process is running for few days and when I restarted that application using pm2 restart. I needed to kill node process manually from task manager. platform: Windows server x64 |
Give it a try with PM2 v0.12.15 and Node.js >= 0.11.x |
Suffering the same thing as the original post. PM2 0.14.2 Because of it. automatic reloading also fails and thus is unusable. Any logs or files that I can help with to try and find a solution? |
Same here. Windows 7 It fails to kill the process, only way to get the port free again is to manually kill the node.exe from process manager. This is what the
|
Same issue and
|
@EddieOne you're on Windows as well ? |
Not sure if it matters at all, but my app does real-time things with Primus. I tried listening for the shutdown signal and gracefully closing the Express and Primus servers, but that didn't fix the issue. |
+1 |
+1 |
I wonder, does this always happen on machines that also have forever globally installed? |
+1 |
FYI, found a possible source of problem on cloud servers. Note : pm2 isn't the same using sudo & no-sudo users |
+1 |
+1 $ node -v $ pm2 -v |
i'm sad to report this bug still exists |
When I kill a pm2 process (http server with expressjs) with the kill command and try to restart the same process without pm2 I get:
If I start the process with pm2, everything is working.
To be able to start the process without pm2, I need to kill the pm2 demon process: 'pm2: Satan Daemonizer'.
Not very practical :).
The text was updated successfully, but these errors were encountered: