pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

pm2 startup systemd - failed because the service did not take the steps required by its unit configuration

Open MarvelousWololo opened this issue 7 years ago • 31 comments
trafficstars

What's going wrong?

Job for pm2-wololo.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status pm2-wololo.service" and "journalctl -xe" for details.

How could we reproduce this issue?

Following this guide https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04

Supporting information

$ pm2 report

===============================================================================
--- PM2 REPORT (Mon Sep 24 2018 04:45:23 GMT+0000 (Coordinated Universal Time)) 
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.1.3
node version         : 10.11.0
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : wololo
uid                  : 1000
gid                  : 1000
uptime               : 12min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.1.3
node version         : 10.11.0
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : wololo
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
cpus nb              : 1
freemem              : 545316864
totalmem             : 1033383936
home                 : /home/wololo
===============================================================================
--- PM2 list -----------------------------------------------
┌──────────┬────┬──────┬──────┬────────┬─────────┬────────┬──────┬───────────┬────────┬──────────┐
│ App name │ id │ mode │ pid  │ status │ restart │ uptime │ cpu  │ mem       │ user   │ watching │
├──────────┼────┼──────┼──────┼────────┼─────────┼────────┼──────┼───────────┼────────┼──────────┤
│ hello    │ 0  │ fork │ 2152 │ online │ 0       │ 5m     │ 0.1% │ 32.9 MB   │ wololo │ disabled │
└──────────┴────┴──────┴──────┴────────┴─────────┴────────┴──────┴───────────┴────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
┌──────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬────────┬──────────┐
│ App name │ id │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem       │ user   │ watching │
├──────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼────────┼──────────┤
│ hello    │ 0  │ fork │ 2152 │ online │ 0       │ 5m     │ 0%  │ 32.9 MB   │ wololo │ disabled │
└──────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

MarvelousWololo avatar Sep 24 '18 04:09 MarvelousWololo

@MarvelousWololo I've hit the same issue... I'll post back if I discover anything.

corywheeler avatar Oct 11 '18 16:10 corywheeler

@MarvelousWololo I ended up shutting down my server and starting it back up... once I did this everything seemed to be working fine.

corywheeler avatar Oct 11 '18 17:10 corywheeler

I had the same issue with the same fix @corywheeler -- I had just barely set up a new ubuntu 18.04 box, and had never rebooted it.

eegrok avatar Oct 18 '18 01:10 eegrok

I had the same issue as @corywheeler and @eegrok. I was able to get things working after a reboot. For those unfamiliar with the command it is: sudo reboot

soundestmammal avatar Mar 18 '19 03:03 soundestmammal

@corywheeler, same here, after the reboot everything works OK. (spend two days on it...) Thanks!

lplip avatar Apr 15 '19 20:04 lplip

I had the same issue. But after run command showed below, pm2 startup systemd started with no error :-) ps aux | grep pm2 | grep -v grep | awk '{print $2}' | xargs kill -9

harupu avatar Jun 06 '19 20:06 harupu

@harupu : It works for me also

piavgh avatar Aug 02 '19 01:08 piavgh

@harupu worked for me as well :pray:

kfth avatar Aug 24 '19 00:08 kfth

@harupu It has also worked for me Thank you

josanescod avatar Nov 06 '19 11:11 josanescod

@harupu: also worked for me. many thx

Perhan35 avatar Dec 15 '19 00:12 Perhan35

Worded for me too

phenomenon01 avatar Jan 16 '20 13:01 phenomenon01

I had the same issue. But after run command showed below, pm2 startup systemd started with no error :-) ps aux | grep pm2 | grep -v grep | awk '{print $2}' | xargs kill -9

Worked for me without the need to restart my server, thank you.

rsalunga29 avatar May 08 '20 13:05 rsalunga29

Didn't try the ps command, but the reboot worked for me :3 Thanks!

MadHuslista avatar May 25 '20 17:05 MadHuslista

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 24 '20 18:06 stale[bot]

Dude, after hours of debugging, restart works! thanks mate

izzuddin-noormy avatar Jul 01 '20 03:07 izzuddin-noormy

Great. It works for me too.

Mortenlk avatar Jul 21 '20 17:07 Mortenlk

I had the same issue. But after run command showed below, pm2 startup systemd started with no error :-) ps aux | grep pm2 | grep -v grep | awk '{print $2}' | xargs kill -9

tnx alot

ASF-ai-tech avatar Sep 04 '20 08:09 ASF-ai-tech

I had the same problem with ubuntu 16, I need to execute pm2 resurrect every time my server has rebooted.

jgante avatar Sep 23 '20 01:09 jgante

I had the same issue. But after run command showed below, pm2 startup systemd started with no error :-) ps aux | grep pm2 | grep -v grep | awk '{print $2}' | xargs kill -9

This is the same as pm2 kill right? - just kill the pm2 master process.

Job for pm2-wololo.service failed because the service did not take the steps required by its unit configuration. See "systemctl status pm2-wololo.service" and "journalctl -xe" for details.

This basically means the pm2 master process should be launched by the systemd, so it can manage it. But in most cases, if you follow the tutorial the master process is launched by yourself. That explains why it works after a restart/kill the master process - you get no pm2 running and the systemd can take over.

I suppose the correct steps to set up your server are:

  1. run pm2 kill to kill the master process if it launched already.
  2. run pm2 startup systemd.
  3. run the command it generates on step 2
    sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u USERNAME --hp /home/USERNAME
    
  4. run sudo service pm2-USERNAME start, now you have a pm2 master process managed by systemd. You can verify it with service pm2-USERNAME status.
  5. run pm2 start your-ecosystem.file to start your apps.
  6. run pm2 save to save your app configuration to /home/USERNAME/.pm2, so systemd launched pm2 master process can resume it from after a server restart.

favoyang avatar Oct 22 '20 16:10 favoyang

@favoyang Thank you, That worked for me very well

titusdishon avatar Mar 29 '21 18:03 titusdishon

@favoyang works like a charm, thank you!

samusaran avatar Sep 26 '21 08:09 samusaran

I had the same issue and resolved with: pm2 kill rm -rf node_modules npm i pm2 start index.js

sudo shutdown -r now

TranslatorDlique avatar May 09 '22 23:05 TranslatorDlique

I had the same issue. But after run command showed below, pm2 startup systemd started with no error :-) ps aux | grep pm2 | grep -v grep | awk '{print $2}' | xargs kill -9

it is work for me than you

lakshan28 avatar May 23 '22 02:05 lakshan28

worked for me after reboot the server

piyumanthaAB avatar Aug 26 '22 14:08 piyumanthaAB

@MarvelousWololo I ended up shutting down my server and starting it back up... once I did this everything seemed to be working fine.

Rebooting the server worked for me, too.

hoseinhakimi avatar Oct 06 '22 10:10 hoseinhakimi

@harupu you save my time 😄

Dan-Doit avatar Dec 02 '22 03:12 Dan-Doit

It seems killing the pm process is the same way as a reboot. Anyway thanks.

TEGRAXD avatar Jul 15 '23 16:07 TEGRAXD

Worked as expected after reboot server

I had the same issue as @corywheeler and @eegrok. I was able to get things working after a reboot. For those unfamiliar with the command it is: sudo reboot

Thanks you Saved my day ^_^

Lalmi-Issam avatar Jul 19 '23 08:07 Lalmi-Issam

Reboot worked for me

Jorg71 avatar Jan 02 '24 14:01 Jorg71

I had the same issue. But after run command showed below, pm2 startup systemd started with no error :-) ps aux | grep pm2 | grep -v grep | awk '{print $2}' | xargs kill -9

this wroked for me in combination with the below

sudo su

The following start command will timeout

systemctl start pm2-USERNAME

Then do this

ausearch -c 'systemd' --raw | audit2allow -M my-systemd semodule -i my-systemd.pp

NOTE: this is NOT a mistake, it has to be done twice

systemctl start pm2-USERNAME

Again, the above start command will timeout

ausearch -c 'systemd' --raw | audit2allow -M my-systemd semodule -i my-systemd.pp systemctl start pm2-USERNAME

Finally the above start command will start the pm2 service, and verify it with

systemctl status pm2-USERNAME

MichaelBoyo avatar Feb 06 '24 21:02 MichaelBoyo