Skip to content

Startup fails if the home directory exists and is empty #2400

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

Closed
sruggier opened this issue Sep 23, 2016 · 2 comments
Closed

Startup fails if the home directory exists and is empty #2400

sruggier opened this issue Sep 23, 2016 · 2 comments
Labels

Comments

@sruggier
Copy link

Steps to reproduce

Startup fails if the home directory exists already, but is empty:

mkdir /tmp/foo
PM2_HOME=/tmp/foo pm2 start app.js --no-daemon

Expected behaviour

When pm2's home directory exists, but is empty, pm2 should automatically create the logs and pids directories instead of failing to start:

$ PM2_HOME=/tmp/foo pm2 start app.js --no-daemon
[...]
pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
2016-09-23 17:20:24: Launching in no daemon mode
2016-09-23 17:20:24: [PM2] Starting /app/app.js in fork_mode (1 instance)
2016-09-23 17:20:24: Starting execution sequence in -fork mode- for app name:app id:0
2016-09-23 17:20:24: App name:app id:0 online
2016-09-23 17:20:24: [PM2] Done.
2016-09-23 17:20:24: ┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬───────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem       │ watching │
├──────────┼────┼──────┼─────┼────────┼─────────┼────────┼─────┼───────────┼──────────┤
│ app      │ 0  │ fork │ 218 │ online │ 0       │ 0s     │ 11% │ 23.3 MB   │ disabled │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴───────────┴──────────┘
2016-09-23 17:20:24:  Use `pm2 show <id|name>` to get more details about an app
2016-09-23 17:20:24: --no-daemon option enabled = do not exit pm2 API
2016-09-23 17:20:24: PM2 daemon PID = 208
2016-09-23 17:20:24: [STREAMING] Now streaming realtime logs for [all] processes
17:20:24 0|app      | Port: 8888

Actual behaviour

pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
2016-09-23 17:15:22: Launching in no daemon mode
2016-09-23 17:15:22: [PM2] Starting /app/app.js in fork_mode (1 instance)
2016-09-23 17:15:22: Starting execution sequence in -fork mode- for app name:app id:0
2016-09-23 17:15:22: Trace: { Error: ENOENT: no such file or directory, open '/tmp/foo/logs/app-out-0.log'
    at Error (native)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/tmp/foo/logs/app-out-0.log' }
    at Object.God.logAndGenerateError (/app/.global/lib/node_modules/pm2/lib/God/Methods.js:51:15)
    at /app/.global/lib/node_modules/pm2/lib/God/ForkMode.js:89:13
    at /app/.global/lib/node_modules/pm2/node_modules/async/lib/async.js:52:16
    at /app/.global/lib/node_modules/pm2/node_modules/async/lib/async.js:696:30
    at /app/.global/lib/node_modules/pm2/node_modules/async/lib/async.js:167:37
    at /app/.global/lib/node_modules/pm2/node_modules/async/lib/async.js:1209:30
    at WriteStream.<anonymous> (/app/.global/lib/node_modules/pm2/lib/Utility.js:137:13)
    at emitOne (events.js:96:13)
    at WriteStream.emit (events.js:188:7)
    at WriteStream.<anonymous> (fs.js:2089:12)
2016-09-23 17:15:22: [PM2] Done.
2016-09-23 17:15:22: ┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬─────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ watching │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴─────┴──────────┘
2016-09-23 17:15:22:  Use `pm2 show <id|name>` to get more details about an app
2016-09-23 17:15:22: --no-daemon option enabled = do not exit pm2 API
2016-09-23 17:15:22: PM2 daemon PID = 197
2016-09-23 17:15:22: [STREAMING] Now streaming realtime logs for [all] processes

Note that the app is missing from the output.

Software versions used

OS         : Debian Jessie
node.js    : 6.6.0
PM2        : 2.0.12 is when the bug was introduced, 1.1.3 doesn't exhibit this behaviour
@Unitech
Copy link
Owner

Unitech commented Sep 26, 2016

Thanks for reporting, just been fixed. If you want to try the dev version:

$ npm install Unitech/pm2#development -g
$ pm2 update

@Unitech
Copy link
Owner

Unitech commented Sep 29, 2016

Landed in latest PM2 stable

$ npm install pm2@latest -g

@Unitech Unitech closed this as completed Sep 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants