I’m setting up a new server and trying now to get pm2 installed and working following this instructions https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04
When trying sudo systemctl start pm2-userName
I get this error message: "Job for pm2-userName.service failed because the service did not take the steps required by its unit configuration."
Any help would be very much appreciated since I am stuck on this. Thanks!"
I have followed this steps until now:
- sudo npm install pm2@latest -g
//(installed fine!)
- pm2 start hello.js
//(working fine!)
- pm2 startup systemd
//(i get a sudo env PATH... to copyPaste)
- copyPasted sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u carles --hp /home/carles
//(and everything looks still fine and working (See STARTUP SCRIPT BELOW)
- sudo pm2 save
(worked)
- sudo systemctl start pm2-carles
(FAILED! as Job for pm2-carles.service failed because the service did not take the steps required by its unit configuration.)
- systemctl status pm2-carles.service
//(loaded but Active: failed (Result: protocol)
STARTUP SCRIPT/// ##########################
[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=carles
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/carles/.pm2
PIDFile=/home/carles/.pm2/pm2.pid
Restart=on-failure
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 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-carles.service
Command list
[ 'systemctl enable pm2-carles' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-carles.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-carles...
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save
[PM2] Remove init script via:
$ pm2 unstartup systemd
#
JOURNALCTL -XE ###############################################
Hint: You are currently not seeing messages from other users and the system.
Users in groups 'adm', 'systemd-journal' can see all messages.
Pass -q to turn off this notice.
Jul 09 09:36:19 future-card pm2[4752]: [PM2] Resurrecting
Jul 09 09:36:19 future-card pm2[4752]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:36:19 future-card pm2[4752]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:36:19 future-card pm2[4752]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:36:19 future-card pm2[4752]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:36:19 future-card pm2[4752]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 33m │ 0
Jul 09 09:36:19 future-card pm2[4752]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:36:19 future-card pm2[4752]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:36:20 future-card pm2[4783]: [PM2] Resurrecting
Jul 09 09:36:20 future-card pm2[4783]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:36:20 future-card pm2[4783]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:36:20 future-card pm2[4783]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:36:20 future-card pm2[4783]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:36:20 future-card pm2[4783]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 33m │ 0
Jul 09 09:36:20 future-card pm2[4783]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:36:20 future-card pm2[4783]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:36:20 future-card pm2[4815]: [PM2] Resurrecting
Jul 09 09:36:20 future-card pm2[4815]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:36:20 future-card pm2[4815]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:36:20 future-card pm2[4815]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:36:20 future-card pm2[4815]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:36:20 future-card pm2[4815]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 33m │ 0
Jul 09 09:36:20 future-card pm2[4815]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:36:20 future-card pm2[4815]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:36:21 future-card pm2[4846]: [PM2] Resurrecting
Jul 09 09:36:21 future-card pm2[4846]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:36:21 future-card pm2[4846]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:36:21 future-card pm2[4846]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:36:21 future-card pm2[4846]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:36:21 future-card pm2[4846]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 33m │ 0
Jul 09 09:36:21 future-card pm2[4846]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:36:21 future-card pm2[4846]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:50:20 future-card pm2[5168]: [PM2] Resurrecting
Jul 09 09:50:20 future-card pm2[5168]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:50:20 future-card pm2[5168]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:50:20 future-card pm2[5168]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:50:20 future-card pm2[5168]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:50:20 future-card pm2[5168]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 47m │ 0
Jul 09 09:50:20 future-card pm2[5168]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:50:20 future-card pm2[5168]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:50:20 future-card pm2[5200]: [PM2] Resurrecting
Jul 09 09:50:20 future-card pm2[5200]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:50:20 future-card pm2[5200]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:50:20 future-card pm2[5200]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:50:20 future-card pm2[5200]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:50:20 future-card pm2[5200]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 47m │ 0
Jul 09 09:50:20 future-card pm2[5200]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:50:20 future-card pm2[5200]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:50:21 future-card pm2[5233]: [PM2] Resurrecting
Jul 09 09:50:21 future-card pm2[5233]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:50:21 future-card pm2[5233]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:50:21 future-card pm2[5233]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:50:21 future-card pm2[5233]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:50:21 future-card pm2[5233]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 47m │ 0
Jul 09 09:50:21 future-card pm2[5233]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:50:21 future-card pm2[5233]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:50:22 future-card pm2[5265]: [PM2] Resurrecting
Jul 09 09:50:22 future-card pm2[5265]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:50:22 future-card pm2[5265]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:50:22 future-card pm2[5265]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:50:22 future-card pm2[5265]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:50:22 future-card pm2[5265]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 47m │ 0
Jul 09 09:50:22 future-card pm2[5265]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:50:22 future-card pm2[5265]: Use `pm2 show <id|name>` to get more details about an app
Jul 09 09:50:23 future-card pm2[5295]: [PM2] Resurrecting
Jul 09 09:50:23 future-card pm2[5295]: [PM2] Restoring processes located in /home/carles/.pm2/dump.pm2
Jul 09 09:50:23 future-card pm2[5295]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬──
Jul 09 09:50:23 future-card pm2[5295]: │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ c
Jul 09 09:50:23 future-card pm2[5295]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼──
Jul 09 09:50:23 future-card pm2[5295]: │ hello │ 0 │ N/A │ fork │ 3268 │ online │ 0 │ 47m │ 0
Jul 09 09:50:23 future-card pm2[5295]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴──
Jul 09 09:50:23 future-card pm2[5295]: Use `pm2 show <id|name>` to get more details about an app```
I expect sudo systemctl start pm2-carles to run and work, instead I am getting "pm2-carles.service - PM2 process manager
Loaded: loaded (/etc/systemd/system/pm2-carles.service; enabled; vendor preset: enabled)
Active: failed (Result: protocol) since Tue 2019-07-09 09:50:23 UTC; 1min 2s ago
Docs: https://pm2.keymetrics.io/
Process: 5295 ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect (code=exited, status=0/SUCCESS)"