Skip to content
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

Cluster mode "ENOENT: no such file or directory, uv_cwd" issue. Doesn't appear to relate to symlinks. #2057

Closed
PaddyMann opened this issue Mar 31, 2016 · 10 comments

Comments

@PaddyMann
Copy link

@PaddyMann PaddyMann commented Mar 31, 2016

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:

  • Moved the entire app to a location that doesn't use symlinks
  • Uninstalled and reinstalled pm2
  • And tested a zillion combinations of factors to try and get around the issue!

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! :)

@mooyoul

This comment has been minimized.

Copy link

@mooyoul mooyoul commented Apr 1, 2016

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.

  1. Type ps ax | grep PM2 on your console and hit Enter.
  2. You'll find your PM2 daemon process row, first column is pid which is Number. remember/note it.
  3. Type ls -l /proc/PM2_PID/cwd
  4. Check working directory is removable (will be removed) directory.

If PM2 running in removable directory. Kill PM2 daemon (pm2 kill) and start pm2 daemon on another directory (e.g. cd ~ && pm2)

@PaddyMann

This comment has been minimized.

Copy link
Author

@PaddyMann PaddyMann commented Apr 1, 2016

@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!

@PaddyMann PaddyMann closed this Apr 1, 2016
@mooyoul

This comment has been minimized.

Copy link

@mooyoul mooyoul commented Apr 1, 2016

Yup, This article - Capistrano-like Deployments might be helpful too. check this out :)

Keep it up @PaddyMann !

@runhwguo

This comment has been minimized.

Copy link

@runhwguo runhwguo commented Sep 21, 2017

1.ps ax | grep PM2
2. kill -9 pid
3.pm2 l

Reference:http://www.hackerav.com/?post=32

@xeoneux

This comment has been minimized.

Copy link

@xeoneux xeoneux commented May 22, 2018

@mooyoul you saved the day :D

falstack referenced this issue in calibur-tv/Avalon Dec 20, 2018
@falstack

This comment has been minimized.

Copy link

@falstack falstack commented Dec 20, 2018

add this in doc?

@paulobressan

This comment has been minimized.

Copy link

@paulobressan paulobressan commented Dec 30, 2018

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.

  1. Digite ps ax | grep PM2no seu console e pressione Enter.
  2. Você encontrará a linha do processo do daemon do PM2, a primeira coluna é pid, que é Number. lembre / anote.
  3. Tipo ls -l /proc/PM2_PID/cwd
  4. 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 exemplo cd ~ && pm2)

Thanks :D

@crobinson42

This comment has been minimized.

Copy link

@crobinson42 crobinson42 commented Aug 20, 2019

Here was my solution:

pm2 kill
rm -rf ~/.pm2 
@caeb92

This comment has been minimized.

Copy link

@caeb92 caeb92 commented Sep 10, 2019

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
@EhsanSarshar

This comment has been minimized.

Copy link

@EhsanSarshar EhsanSarshar commented Oct 25, 2019

for me this work
pm2 kill
and then start it

thanks @mooyoul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.