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

Systemd not recognizing PM2 as being online #2354

Closed
timcosta opened this issue Aug 22, 2016 · 2 comments
Closed

Systemd not recognizing PM2 as being online #2354

timcosta opened this issue Aug 22, 2016 · 2 comments

Comments

@timcosta
Copy link

Given the following inputs:

[Unit]
Description=PM2 next gen process manager for Node.js
After=network.target remote-fs.target

[Service]
Type=forking
PIDFile=/var/app/myapp/.pm2/pm2.pid
User=myapp

ExecStartPre=/usr/lib/node_modules/pm2/bin/pm2 kill
ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all

ExecStop=/usr/lib/node_modules/pm2/bin/pm2 dump
ExecStop=/usr/lib/node_modules/pm2/bin/pm2 delete all
ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill

[Install]
WantedBy=multi-user.target

and

$ sudo su -c 'pm2 ls' myapp
┌────────────────────────────────┬────┬─────────┬──────┬────────┬─────────┬────────┬──────────────┬──────────┐
│ App name                       │ id │ mode    │ pid  │ status │ restart │ uptime │ memory       │ watching │
├────────────────────────────────┼────┼─────────┼──────┼────────┼─────────┼────────┼──────────────┼──────────┤
│ myapp              │ 0  │ cluster │ 5460 │ online │ 0       │ 7m     │ 126.680 MB   │ disabled │
│ myapp              │ 1  │ cluster │ 5469 │ online │ 0       │ 7m     │ 120.340 MB   │ disabled │
│ myapp-auth              │ 2  │ fork    │ 5510 │ online │ 0       │ 7m     │ 34.160 MB    │ disabled │
│ myapp-worker       │ 3  │ fork    │ 5523 │ online │ 0       │ 7m     │ 34.285 MB    │ disabled │
│myapp-worker2 │ 4  │ fork    │ 5526 │ online │ 0       │ 7m     │ 37.078 MB    │ disabled │
└────────────────────────────────┴────┴─────────┴──────┴────────┴─────────┴────────┴──────────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

Expected behaviour

Systemd should recognize this service as being online.

Actual behaviour

$ sudo systemctl status pm2-myapp.service
.snip.
Active: inactive (dead) since Mon 2016-08-22 19:14:45 UTC; 4min 46s ago
.snip.

Steps to reproduce

pm2 startup systemd

Software versions used

OS         : Ubuntu 16.04
node.js    : 5.12.0, 6.3.1
PM2        : 1.1.3, next

PM2 Log output

Use the command: tail --lines 50 ~/.pm2/pm2.log

2016-08-22 19:28:10: Starting execution sequence in -cluster mode- for app name:myapp id:0
2016-08-22 19:28:10: App name:myapp id:0 online
2016-08-22 19:28:10: Starting execution sequence in -cluster mode- for app name:myapp id:1
2016-08-22 19:28:11: App name:myapp id:1 online
2016-08-22 19:28:11: Starting execution sequence in -fork mode- for app name:myapp-auth id:2
2016-08-22 19:28:11: App name:myapp-auth id:2 online
2016-08-22 19:28:11: Starting execution sequence in -fork mode- for app name:myapp-worker id:3
2016-08-22 19:28:11: App name:myapp-worker id:3 online
2016-08-22 19:28:11: Starting execution sequence in -fork mode- for app name:myapp-worker2 id:4
2016-08-22 19:28:11: App name:myapp-worker2 id:4 online
2016-08-22 19:28:22: Stopping app:myapp id:0
2016-08-22 19:28:23: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:23: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:23: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:23: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:24: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:25: Process with pid 6936 still not killed, retrying...
2016-08-22 19:28:25: Process with pid 6936 still alive after 1600ms, sending it SIGKILL now...
2016-08-22 19:28:25: App name:myapp id:0 disconnected
2016-08-22 19:28:25: App [myapp] with id [0] and pid [6936], exited with code [0] via signal [SIGKILL]
2016-08-22 19:28:25: [HandleExit] PM2 is being killed, stopping restart procedure...
2016-08-22 19:28:25: Stopping app:myapp id:1
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:26: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:27: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:27: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:27: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:27: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:27: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:27: Process with pid 6945 still not killed, retrying...
2016-08-22 19:28:27: Process with pid 6945 still alive after 1600ms, sending it SIGKILL now...
2016-08-22 19:28:27: App name:myapp id:1 disconnected
2016-08-22 19:28:27: App [myapp] with id [1] and pid [6945], exited with code [0] via signal [SIGKILL]
2016-08-22 19:28:27: [HandleExit] PM2 is being killed, stopping restart procedure...
2016-08-22 19:28:27: Stopping app:myapp-auth id:2
@vmarchaud
Copy link
Contributor

@tjsail33 The problem looks like coming from the pid dir : PIDFile=/var/app/myapp/.pm2/pm2.pid, by default the pid file of pm2 is on ~/.pm2/pm2.pid. Could you test by replacing the pid file ?

@Unitech
Copy link
Owner

Unitech commented Dec 6, 2016

Closing in favor of #2559

To try the new startup system:

$ npm install Unitech/pm2#development -g
$ pm2 update
$ pm2 startup     # Then copy / paste the command displayed
$ pm2 unstartup

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

No branches or pull requests

3 participants