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

Created on 31 Mar 2016  ·  10Comments  ·  Source: Unitech/pm2

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

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.

  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)

All 10 comments

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)

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

1.ps ax | grep PM2

  1. kill -9 pid
    3.pm2 l

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

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

  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

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

Was this page helpful?
0 / 5 - 0 ratings