Comments (49)
i'm sad to report this bug still exists
from pm2.
+1
from pm2.
+1
RHEL7
node v0.10.36
pm2 1.0.0
I literally need to reboot the server every time a process goes rogue since trying to do a kill -9 <PID>
based upon the output of netstat -nltp | grep 3000
, says the process doesn't exist, yet somehow blocking my port 3000! Also pm2 list
or pm2 monit
says nothing is running.
from pm2.
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 pm2 stop <pm2_id|script_name|all>
. pm2 kill
is only to kill pm2.
Which node version do you use ?
Thanks
from pm2.
my mistake, It's was about pm2 stop ;) and not kill.
node version: 0.10.17
from pm2.
I confirm there is a bug with node v0.10.x the port is not freed when stopping the process with pm2 stop
.
With v0.8.x and v0.11.x there isn't this bug.
I will try to have a deeper look at it, thanks for reporting this issue
from pm2.
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.
from pm2.
Having the same issue with 0.10.. I had to make my git push hook kill and start the pm2 daemon
from pm2.
It happens everytime for me, I'm still on node 0.8.25.
from pm2.
@Unitech http://nodejs.org states: Current Version: v0.10.19
great if we could get read of this major bug on 0.10.x
pm2 kill on github webhooks makes no fun :(
from pm2.
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
from pm2.
i haven't found any solution to fix that.
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.
from pm2.
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?
from pm2.
You can get this to happen when you shut down node improperly. Its a node
error not pm2, although i feel that if pm2 shuts node down differently it
may solve the issue you have
Matej Kramny
On 12 Oct 2013, at 01:28 pm, "☮ elf Pavlik ☮" [email protected]
wrote:
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?
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/74#issuecomment-26196575
.
from pm2.
@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
from pm2.
I'm scarred that all this mechanism comes from C++ modules and not the cluster.js, I will have a look at it
cluster.js doesn't even require any native modules, but base around process.send(message, fd)
function which I believe is the same in 0.12, 0.10 and even 0.8. Can't be sure though.
from pm2.
@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 -x
parameter.
To beneficiate of the fork mode you have to install at least the 0.6.3 version of pm2
$ npm install -g pm2@latest
I've added a section "known bugs" in the README.md : https://github.com/Unitech/pm2#known-bugs
Thanks for reporting, closing
from pm2.
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)
})
}
from pm2.
Did you ever report this to joyent/node?
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.
Do you have a simple reproduction? Below doesn't cause any listen socket leak.
Instead of cluster.fork
in setTimeout run another process (not fork) that will try to bind the same port. If all workers exit, it should bind successfully, but on 0.10 it won't.
from pm2.
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 pm2 stop
is implemented, consider calling cluster.disconnect()
when you know you have no more workers (like, after they have all been stopped), it will close the server handles. See gist linked to by nodejs/node-v0.x-archive#6554.
from pm2.
Anyhow, @Unitech, depending on how pm2 stop is implemented, consider calling cluster.disconnect() when you know you have no more workers
You can call pm2 kill
instead to stop it completely.
I'm doing it quite often when I forget the difference between "stop" and "kill" :)
from pm2.
What is the resolution / workaround for this? It's still occurring for me on v0.10.24
.
from pm2.
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]
wrote:
What is the resolution / workaround for this? It's still occurring for me
on v0.10.24.
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/74#issuecomment-33041863
.
from pm2.
^Z
should pause an app, not kill -- the port should remain in use in this case (you can resume with bg
or fg
for backgrounding or foregrounding the process, respectively).
from pm2.
Oh. Hmm.
Well i was referring to a problem which i encountered during development of
an app, while using nodemon.
My app would crash, and port remained open after restart.
I could solve this by visiting the url (which strangely still sent some of
the content). Visiting again would return 404, after which the port was
usable again.
Matej Kramny
On 22 Jan 2014, at 04:59 pm, Eric Martindale [email protected]
wrote:
^Z should pause an app, not kill -- the port should remain in use in this
case (you can resume with bg or fg for backgrounding or foregrounding the
process, respectively).
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/74#issuecomment-33043051
.
from pm2.
So how do I solve this? Upgrade node to 0.11.2?
from pm2.
Upgrade node to latest version in 0.11.x branch. It's 0.11.11 now.
from pm2.
@rlidwka: I just saw an update from 0.10.25 to 0.10.26 last week, so it's still maintained. Might be worth bugging Joyent.
from pm2.
are you sure it's still the same process ? can you have lock at the pid and confirm ?
from pm2.
it still happen..how to solve it?
from pm2.
@goldalworming , update to node 0.11.x?
from pm2.
in nodejs.org Current Version: v0.10.31
I use pm2 in production..I haven't test the application in 0.11..
from pm2.
gracefulStop (not available) that sends a shutdown
message to the application so you can app.close()
and so free the port ?
Btw currently the solutions are:
- use Node.js v0.11.13
or pm2 kill
when you need to free the port in order to run your app without pm2
or- run your app in fork mode
from pm2.
I experience the same issue and I am running in fork mode on node 0.10.31. Can you elaborate on that, @Unitech ?
from pm2.
@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?
from pm2.
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.
from pm2.
I'm sure that it's [email protected]'s problem. The [email protected] works fine.
On [email protected] later, "exec_mode": "cluster_mode"
was fallback to fork_mode
from pm2.
Same problem with pm2 0.12.10
Tried with pm2 stop, pm2 restart, pm2 kill.
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
pm2 version: 0.12.10
from pm2.
Give it a try with PM2 v0.12.15 and Node.js >= 0.11.x
from pm2.
Suffering the same thing as the original post.
PM2 0.14.2
Node v0.12.4
Windows 8
Because of it. automatic reloading also fails and thus is unusable.
Only way to start my server again is to kill the node process from task manager and start again.
Any logs or files that I can help with to try and find a solution?
from pm2.
Same here.
Windows 7
pm2 0.14.3
node 0.12.2
npm 2.7.4
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 pm2 logs
shows when trying to do pm2 restart app
PM2 Stopping app:app id:0
PM2 7620 pid can not be killed { [Error: kill ESRCH] code: 'ESRCH', errno: 'ESRCH', syscall: 'kill' }
PM2 Starting execution sequence in -fork mode- for app name:app id:0
PM2 App name:app id:0 online
from pm2.
Same issue and ESRCH
error with the following config:
- Windows 8.1
- pm2 0.14.5
- node 0.12.4
- npm 2.11.3
from pm2.
@EddieOne you're on Windows as well ?
from pm2.
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.
from pm2.
+1
from pm2.
+1
node v0.12.7
pm2 0.15.10
osx 10.11.1
from pm2.
I wonder, does this always happen on machines that also have forever globally installed?
from pm2.
FYI, found a possible source of problem on cloud servers.
pm2 was launched by default as a sudo process in my automatic script, so when I was trying to relaunch one as a normal user I should be careful to use sudo.
Note : pm2 isn't the same using sudo & no-sudo users
from pm2.
+1
$ uname -a
Linux xxx 2.6.32-573.8.1.el6.x86_64 #1 SMP Tue Nov 10 18:01:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ node -v
v8.9.3
$ pm2 -v
2.9.1
from pm2.
Related Issues (20)
- CLOSE
- Gives error cannot resolve pty.js and test.js
- PM2 Bucket is not launching on pm2 website
- [PM2] Spawning PM2 daemon with pm2_home/root/.pm2 HOT 1
- Unable to start scripts through npm
- `pm2 show` should display exp_backoff_restart_delay value if specified
- [RFC] - What can be the pros and cons if we use the PM2 with the node apps in Openshift and Kubernetes
- pm2 : Script /usr/bin/java had too many unstable restarts (16). Stopped. "errored"
- pm2 start app returning 502
- How to implement cross server application management in PM2 HOT 2
- Hot Code Swap HOT 1
- Process list incomplete after reboot HOT 6
- Simultaneous Deployments
- One-time process enqueue
- Monitor the exit of child processes
- Allow ecosystem config to be in TypeScript
- PM2 I/O is not linking
- Help and report commands don't work until the daemon starts
- PM2 error: TypeError: One of the pids provided is invalid
- watch for changes is only on a folder level. we need to watch a file.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pm2.