Startup script doesn't work on ubuntu 18.04
Run pm2 startup on ubuntu 18.04 and copy the script.
The service seems to install but pm2 doesn't start when running sudo service start pm2
Can you show me the content of the startup script? (cat /etc/systemd/system/pm2*)
I ran this command:
sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u admin --hp /home/admin
Which resulted in this output:
[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=admin
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/admin/.pm2
PIDFile=/home/admin/.pm2/pm2.pid
ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-admin.service
Command list
[ 'systemctl enable pm2-admin',
'systemctl start pm2-admin',
'systemctl daemon-reload',
'systemctl status pm2-admin' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-admin.service
[PM2] Making script booting at startup...
>>> Executing systemctl enable pm2-admin
Created symlink /etc/systemd/system/multi-user.target.wants/pm2-admin.service โ /etc/systemd/system/pm2-admin.service.
[DONE]
>>> Executing systemctl start pm2-admin
Job for pm2-admin.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status pm2-admin.service" and "journalctl -xe" for details.
[ERROR] Exit code : 1
[PM2][ERROR] systemctl start pm2-admin failed, see error above.
Contents of /etc/systemd/system/pm2-admin.service:
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=admin
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/admin/.pm2
PIDFile=/home/admin/.pm2/pm2.pid
ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
I have reproduced the error
look like an issue on systemd https://github.com/systemd/systemd/issues/8085
Trying to find a solution
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/ubuntu/.pm2
PIDFile=/home/ubuntu/.pm2/pm2.pid
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-ubuntu.service
Command list
[ 'systemctl enable pm2-ubuntu',
'systemctl start pm2-ubuntu',
'systemctl daemon-reload',
'systemctl status pm2-ubuntu' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-ubuntu.service
[PM2] Making script booting at startup...
>>> Executing systemctl enable pm2-ubuntu
Created symlink /etc/systemd/system/multi-user.target.wants/pm2-ubuntu.service โ /etc/systemd/system/pm2-ubuntu.service.
[DONE]
>>> Executing systemctl start pm2-ubuntu
[DONE]
>>> Executing systemctl daemon-reload
[DONE]
>>> Executing systemctl status pm2-ubuntu
โ pm2-ubuntu.service - PM2 process manager
Loaded: loaded (/etc/systemd/system/pm2-ubuntu.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-05-10 17:11:52 UTC; 1s ago
Docs: https://pm2.keymetrics.io/
Main PID: 2680 (PM2 v2.10.3: Go)
Tasks: 10 (limit: 2296)
CGroup: /system.slice/pm2-ubuntu.service
โโ2680 PM2 v2.10.3: God Daemon (/home/ubuntu/.pm2)
Landed on master, it will be published soon
I just ran into the same problem. @Unitech Thank you for the quick solution!
$ npm install Unitech/pm2 -g
Same issue on 2.10.3
sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u admin --hp /home/admin
[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=admin
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/admin/.pm2
PIDFile=/home/admin/.pm2/pm2.pid
ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-admin.service
Command list
[ 'systemctl enable pm2-admin',
'systemctl start pm2-admin',
'systemctl daemon-reload',
'systemctl status pm2-admin' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-admin.service
[PM2] Making script booting at startup...
>>> Executing systemctl enable pm2-admin
Created symlink /etc/systemd/system/multi-user.target.wants/pm2-admin.service โ /etc/systemd/system/pm2-admin.service.
[DONE]
>>> Executing systemctl start pm2-admin
Job for pm2-admin.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status pm2-admin.service" and "journalctl -xe" for details.
[ERROR] Exit code : 1
[PM2][ERROR] systemctl start pm2-admin failed, see error above.
Can confirm having the same issue, uninstalling PM2 and installing from Unitech/pm2 doesn't seem to do anything for the issue.
@Unitech - I don't understand your solution. Your description of throttling systemctl commands doesn't translate into anything I can replicate. How do you "throttle" systemctl commands?
$ pm2 unstartup
$ npm install Unitech/pm2 -g
$ pm2 startup
Release in progress
@mag911 I mean putting a timer between each systemctl commands
([ 'systemctl enable pm2-ubuntu',
'systemctl start pm2-ubuntu',
'systemctl daemon-reload',
'systemctl status pm2-ubuntu' ])
OK, it look like that when the daemon is running the startup command fail...
If you do pm2 kill and then run the pm2 startup command, it works... Looking for a fix
Do anyone here has an idea on how to fix this systemd script? https://github.com/Unitech/pm2/blob/master/lib/templates/init-scripts/systemd.tpl
ok guys, I've skipped some command if the daemon is still running. It runs smoothly now.
$ pm2 unstartup
$ npm install Unitech/pm2 -g
$ pm2 startup
Published now:
$ pm2 unstartup
$ npm install pm2@latest -g
$ pm2 startup
Many thanks!
Currently at another job, will try in 8 hours.
Cheers :)
On 18 May 2018, at 12:13 am, Alexandre Strzelewicz <[email protected]notifications@github.com> wrote:
Published now:
$ pm2 unstartup
$ npm install pm2@latest -g
$ pm2 startup
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/Unitech/pm2/issues/3645#issuecomment-389923044, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AbarymET-3DJI4XI8kcdqggkeQSJ0YTOks5tzaHFgaJpZM4Ty_vz.
This message and any attached files may contain information that is confidential and/or subject of legal privilege intended only for use by the intended recipient. If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, be advised that you have received this message in error and that any dissemination, copying or use of this message or attachment is strictly forbidden, as is the disclosure of the information therein. If you have received this message in error please notify the sender immediately and delete the message.
Issue seems to be resolved. Thanks!
Still receiving the same error after installing 2.10.4
[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=admin
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/admin/.pm2
PIDFile=/home/admin/.pm2/pm2.pid
ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-admin.service
Command list
[ 'systemctl enable pm2-admin',
'systemctl start pm2-admin',
'systemctl daemon-reload',
'systemctl status pm2-admin' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-admin.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-admin...
Created symlink /etc/systemd/system/multi-user.target.wants/pm2-admin.service โ /etc/systemd/system/pm2-admin.service.
[PM2] [v] Command successfully executed.
[PM2] [-] Executing: systemctl start pm2-admin...
Job for pm2-admin.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status pm2-admin.service" and "journalctl -xe" for details.
[ERROR] Exit code : 1
[PM2][ERROR] systemctl start pm2-admin failed, see error above.
It initially failed for me too using 2.10.4, but eventually got it working:
after running the above commands to upgrade, but before I ran pm2 startup
1) pm2 delete all
2) pm2 start ...
3) pm2 save. Although this told me to pm2 update
then
pm2 startup.
fixed in development:
$ npm install Unitech/pm2#development -g
$ pm2 update
I'm getting the same issue on a fresh install of Ubuntu 18.04 using pm2 v3.1.2
...failed because the service did not take the steps required by its unit configuration
Here's the journalctl -xe output:
-- The start-up result is RESULT.
Sep 13 19:01:06 myapp sudo[3230]: usr : TTY=pts/0 ; PWD=/home/usr/app ; USER=root ; COMMAND=/usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd
Sep 13 19:01:06 myapp sudo[3230]: pam_unix(sudo:session): session opened for user root by usr(uid=0)
Sep 13 19:01:06 myapp systemd[1]: Reloading.
Sep 13 19:01:07 myapp sudo[3230]: pam_unix(sudo:session): session closed for user root
Sep 13 19:01:28 myapp polkitd(authority=local)[1141]: Registered Authentication Agent for unix-process:3266:40050 (system bus name :1.14 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Sep 13 19:01:32 myapp polkitd(authority=local)[1141]: Operator of unix-process:3266:40050 successfully authenticated as unix-user:usr to gain ONE-SHOT authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.15 [systemctl start pm2-usr] (owned b
Sep 13 19:01:32 myapp systemd[1]: Starting PM2 process manager...
-- Subject: Unit pm2-usr.service has begun start-up
-- Defined-By: systemd
-- Support: http://usrw.ubuntu.com/support
--
-- Unit pm2-usr.service has begun starting up.
Sep 13 19:01:32 myapp pm2[3276]: [PM2] Resurrecting
Sep 13 19:01:32 myapp pm2[3276]: [PM2] Restoring processes located in /home/usr/.pm2/dump.pm2
Sep 13 19:01:32 myapp pm2[3276]: [PM2][ERROR] Failed to read dump file in /home/usr/.pm2/dump.pm2
Sep 13 19:01:32 myapp pm2[3276]: [PM2] Restoring processes located in /home/usr/.pm2/dump.pm2
Sep 13 19:01:32 myapp pm2[3276]: [PM2][ERROR] Failed to read dump file in /home/usr/.pm2/dump.pm2.bak
Sep 13 19:01:32 myapp pm2[3276]: [PM2][ERROR] No processes saved; DUMP file doesn't exist
Sep 13 19:01:32 myapp pm2[3276]: โโโโโโโโโโโโฌโโโโโฌโโโโโโโฌโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโ
Sep 13 19:01:32 myapp pm2[3276]: โ App name โ id โ mode โ pid โ status โ restart โ uptime โ cpu โ mem โ user โ watching โ
Sep 13 19:01:32 myapp pm2[3276]: โโโโโโโโโโโโผโโโโโผโโโโโโโผโโโโโโโผโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโผโโโโโโโผโโโโโโโโโโโโผโโโโโโโผโโโโโโโโโโโค
Sep 13 19:01:32 myapp pm2[3276]: โ myapp โ 0 โ fork โ 3206 โ online โ 0 โ 42s โ 0.1% โ 35.6 MB โ usr โ disabled โ
Sep 13 19:01:32 myapp pm2[3276]: โโโโโโโโโโโโดโโโโโดโโโโโโโดโโโโโโโดโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโดโโโโโโโดโโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโ
Sep 13 19:01:32 myapp pm2[3276]: Use `pm2 show <id|name>` to get more details about an app
Sep 13 19:01:32 myapp systemd[1]: pm2-usr.service: New main PID 3195 does not belong to service, and PID file is not owned by root. Refusing.
Sep 13 19:01:32 myapp systemd[1]: pm2-usr.service: New main PID 3195 does not belong to service, and PID file is not owned by root. Refusing.
Sep 13 19:01:32 myapp systemd[1]: pm2-usr.service: Failed with result 'protocol'.
Sep 13 19:01:32 myapp systemd[1]: Failed to start PM2 process manager.
-- Subject: Unit pm2-usr.service has failed
-- Defined-By: systemd
-- Support: http://usrw.ubuntu.com/support
--
-- Unit pm2-usr.service has failed.
--
-- The result is RESULT.
Sep 13 19:01:32 myapp polkitd(authority=local)[1141]: Unregistered Authentication Agent for unix-process:3266:40050 (system bus name :1.14, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
I'm unable to start the pm2 service. Is there a fix or workaround for this?
@anomaaly did you manage to find a fix? thanks.
@anomaaly did you manage to find a fix? thanks.
had the same issue just now. sudo fixed it
sudo pm2 startup
@MarvelousWololo @SkyJedi No, the same thing happened when I installed on a newly created vm. However, after running pm2 save and rebooting, I found the systemd service running just fine.
Most helpful comment
OK, it look like that when the daemon is running the startup command fail...
If you do
pm2 killand then run the pm2 startup command, it works... Looking for a fixDo anyone here has an idea on how to fix this systemd script? https://github.com/Unitech/pm2/blob/master/lib/templates/init-scripts/systemd.tpl