When I start pm2 in cluster mode (on a dedicated Ubuntu 14.04 server), I get the following error:
PM2: 2016-03-31 15:33:38: Script /var/www/vhosts/api/v2/dist/server/server.js had too many unstable restarts (16). Stopped. "errored"
PM2: 2016-03-31 15:33:38: App name:server id:1 online
PM2: path.js:1184
PM2: cwd = process.cwd();
PM2: ^
PM2:
PM2: Error: ENOENT: no such file or directory, uv_cwd
PM2: at Error (native)
PM2: at Object.resolve (path.js:1184:25)
PM2: at Function.Module._resolveLookupPaths (module.js:263:17)
PM2: at Function.Module._resolveFilename (module.js:330:31)
PM2: at Function.Module._load (module.js:290:25)
PM2: at Module.require (module.js:367:17)
PM2: at require (internal/module.js:16:19)
PM2: at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainer.js:7:15)
PM2: at Module._compile (module.js:413:34)
PM2: at Object.Module._extensions..js (module.js:422:10)
PM2: 2016-03-31 15:33:38: App name:server id:1 disconnected
PM2: 2016-03-31 15:33:38: App [server] with id [1] and pid [22249], exited with code [1] via signal [SIGINT]
PM2: 2016-03-31 15:33:38: Script /var/www/vhosts/api/v2/dist/server/server.js had too many unstable restarts (16). Stopped. "errored"
This appears similar to #1623 but in that issue it appears that for most people it related to using symlinks and removing use of symlinks fixed the issue.
I was originally using symlinks but haven't been able to get around the issue.
I have now:
Whenever I start pm2, either with pm2 start server.js -i 2, or with a JSON config file, it leads to the above error (if it's set to cluster mode). Works fine in forked mode.
Any ideas? I'm slowly going crazy! :)
DId you check PM2's its own Working Directory (pwd)?
PM2 daemon's working directory should not be in removable directory.
So, How to check PM2's working directory?
It's easy. Try this methods.
ps ax | grep PM2 on your console and hit Enter.ls -l /proc/PM2_PID/cwdIf PM2 running in removable directory. Kill PM2 daemon (pm2 kill) and start pm2 daemon on another directory (e.g. cd ~ && pm2)
@mooyoul thank you - I owe you so many beers!
Could have sworn I had killed PM2 and addressed this, but you were spot on and PM2 was running in a deleted directory.
Thank you!
Yup, This article - Capistrano-like Deployments might be helpful too. check this out :)
Keep it up @PaddyMann !
@mooyoul you saved the day :D
add this in doc?
Você verificou o PM2 do seu próprio diretório de trabalho (pwd)?
O diretório de trabalho do daemon do PM2 não deve estar no diretório removível.Então, como verificar o diretório de trabalho do PM2?
É fácil. Tente este método.
- Digite
ps ax | grep PM2no seu console e pressione Enter.- Você encontrará a linha do processo do daemon do PM2, a primeira coluna é pid, que é Number. lembre / anote.
- Tipo
ls -l /proc/PM2_PID/cwd- Verificar o diretório de trabalho é removível (será removido) diretório.
Se o PM2 estiver executando no diretório removível. Matar o daemon PM2 (
pm2 kill) e iniciar o daemon do pm2 em outro diretório (por exemplocd ~ && pm2)
Thanks :D
Here was my solution:
pm2 kill
rm -rf ~/.pm2
I have similar problem with PM2 V3.5.1, my app run ok with in fork mode but fails in cluster or more than one instance, this was my solution.
ps -fea | grep pm2
kill -9 [PM2_PID]
rm -rf ~/.pm2
for me this work
pm2 kill
and then start it
thanks @mooyoul
Most helpful comment
DId you check PM2's its own Working Directory (pwd)?
PM2 daemon's working directory should not be in removable directory.
So, How to check PM2's working directory?
It's easy. Try this methods.
ps ax | grep PM2on your console and hit Enter.ls -l /proc/PM2_PID/cwdIf PM2 running in removable directory. Kill PM2 daemon (
pm2 kill) and start pm2 daemon on another directory (e.g.cd ~ && pm2)