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 · 12 comments

Comments

@PaddyMann
Copy link

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
Copy link

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
Copy link
Author

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

@mooyoul
Copy link

mooyoul commented Apr 1, 2016

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

Keep it up @PaddyMann !

@runhwguo
Copy link

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

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

@xeoneux
Copy link

xeoneux commented May 22, 2018

@mooyoul you saved the day :D

@falstack
Copy link

add this in doc?

@paulobressan
Copy link

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
Copy link

Here was my solution:

pm2 kill
rm -rf ~/.pm2 

@caeb92
Copy link

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

@byteab
Copy link

byteab commented Oct 25, 2019

for me this is working
pm2 kill
and then start it again

thanks @mooyoul

@myllenacruz
Copy link

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)

this really works! thank you!

@aderchox
Copy link

aderchox commented Apr 3, 2023

Does this mean that PM2 cluster mode will not be usable on WSL2 as well?
I also didn't manage to get it to work on Windows Powershell v7.

UPDATE: Yeah it seems that PM2 cluster mode works neither on Windows PWSH7 nor on WSL2 Ubuntu.
It works on an Ubuntu on VPS though. I have no idea about Windows Pwsh7, probably PM2 didn't have Windows in mind for cluster mode, but in case of WSL2 Ubuntu, I guess it has to do with how Windows treats drives as mounted mediums (removables, i.e., what the first comment under this issue talks about).

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

No branches or pull requests