Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.57k stars 2.62k forks source link

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

Open MarvelousWololo opened 6 years ago

MarvelousWololo commented 6 years ago

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
corywheeler commented 6 years ago

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

corywheeler commented 6 years ago

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

eegrok commented 6 years ago

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.

soundestmammal commented 5 years ago

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

lplip commented 5 years ago

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

harupu commented 5 years ago

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

piavgh commented 5 years ago

@harupu : It works for me also

kfth commented 5 years ago

@harupu worked for me as well :pray:

josanescod commented 5 years ago

@harupu It has also worked for me Thank you

Perhan35 commented 4 years ago

@harupu: also worked for me. many thx

phenomenon01 commented 4 years ago

Worded for me too

rsalunga29 commented 4 years ago

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.

MadHuslista commented 4 years ago

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

stale[bot] commented 4 years ago

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.

izzuddin-noormy commented 4 years ago

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

Mortenlk commented 4 years ago

Great. It works for me too.

ASF-ai-tech commented 4 years ago

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

jgante commented 4 years ago

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

favoyang commented 4 years ago

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.
titusdishon commented 3 years ago

@favoyang Thank you, That worked for me very well

samusaran commented 3 years ago

@favoyang works like a charm, thank you!

TranslatorDlique commented 2 years ago

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

sudo shutdown -r now

lakshan28 commented 2 years ago

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

piyumanthaAB commented 2 years ago

worked for me after reboot the server

hoseinhakimi commented 2 years ago

@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.

Dan-Doit commented 1 year ago

@harupu you save my time 😄

TEGRAXD commented 1 year ago

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

Lalmi-Issam commented 1 year ago

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 ^_^

Jorg71 commented 10 months ago

Reboot worked for me

MichaelBoyo commented 9 months ago

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

HYUNSOOSHIN commented 7 months ago

감사합니다