Closed austintoddj closed 2 years ago
Could you run sudo service --status-all
and give me the output ? Also could you check that the file ~/.pm2/dump.pm2
is not empty (should contains all processes metadatas) ?
@vmarchaud Here is the output of sudo service --status-all
:
[ + ] acpid
[ + ] apache-htcacheclean
[ + ] apache2
[ + ] apparmor
[ + ] apport
[ + ] atd
[ - ] bootmisc.sh
[ - ] checkfs.sh
[ - ] checkroot-bootclean.sh
[ - ] checkroot.sh
[ + ] console-setup
[ + ] cron
[ - ] cryptdisks
[ - ] cryptdisks-early
[ + ] dbus
[ + ] denyhosts
[ + ] fail2ban
[ + ] grub-common
[ - ] hostname.sh
[ - ] hwclock.sh
[ + ] irqbalance
[ + ] iscsid
[ - ] keyboard-setup.dpkg-bak
[ - ] killprocs
[ + ] kmod
[ - ] lvm2
[ + ] lvm2-lvmetad
[ + ] lvm2-lvmpolld
[ + ] lxcfs
[ - ] lxd
[ + ] mdadm
[ - ] mdadm-waitidle
[ - ] mountall-bootclean.sh
[ - ] mountall.sh
[ - ] mountdevsubfs.sh
[ - ] mountkernfs.sh
[ - ] mountnfs-bootclean.sh
[ - ] mountnfs.sh
[ + ] mysql
[ + ] networking
[ + ] ondemand
[ + ] open-iscsi
[ - ] plymouth
[ - ] plymouth-log
[ + ] postfix
[ + ] procps
[ + ] rc.local
[ + ] resolvconf
[ - ] rsync
[ + ] rsyslog
[ - ] screen-cleanup
[ - ] sendsigs
[ + ] ssh
[ + ] udev
[ + ] ufw
[ - ] umountfs
[ - ] umountnfs.sh
[ - ] umountroot
[ + ] unattended-upgrades
[ + ] urandom
[ - ] uuidd
And I did verify that the file at ~/.pm2/dump.pm2 is NOT empty.
looks like you didn't run pm2 startup
because you don't have pm2 service listed here
@vmarchaud Ran both pm2 startup
and sudo pm2 startup
and neither made pm2
show up in that list. Any idea why?
Because pm2 startup
just output you the command you need to run to register itself
@vmarchaud Ok, ran the startup
command AND then this: sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u austintoddj --hp /home/austintoddj
and still nothing shows up in the services list. Ideas?
@vmarchaud Here are the contents of ~/.pm2/dump.pm2
. Does this give any insight?
...
Nope, can you try to ls /etc/systemd/system
to see if the service is written to the disk ?
@vmarchaud Here's the output of that:
cloud-init.target.wants getty.target.wants multi-user.target.wants pm2-austintoddj.service sshd.service timers.target.wants
default.target.wants graphical.target.wants network-online.target.wants pm2-root.service sysinit.target.wants udev-finish.service
final.target.wants iscsi.service paths.target.wants sockets.target.wants syslog.service
having the same problem.
pm2 -v 2.6.1
node -v v6.11.0
npm -v 3.10.10
lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.3 LTS Release: 16.04 Codename: xenial
service --status-all [ + ] pm2-dd
/etc/systemd/system/pm2-dd.service exists
I can start up all the processes by doing a pm2 resurrect every boot no problem
This was updated from an earlier ubuntu 14. don't think it matters, but at this point ill add any data.
@nivoset You should have a daemon running on boot but under user dd
@austintoddj Checkout that service are running with sudo service pm2-root status
and sudo service pm2-austintoddj status
, you have two daemon registered, maybe that you aren't connected to the good one.
@vmarchaud So here's the output when I run the commands you gave me:
sudo service pm2-root status
...outputs:
● pm2-root.service - PM2 process manager
Loaded: loaded (/etc/systemd/system/pm2-root.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Tue 2017-09-19 08:21:33 EDT; 2 days ago
Docs: https://pm2.keymetrics.io/
Sep 19 08:20:03 whispering-ocean systemd[1]: Starting PM2 process manager...
Sep 19 08:20:08 whispering-ocean pm2[1261]: [PM2] Spawning PM2 daemon with pm2_home=/home/austintoddj/.pm2
Sep 19 08:21:33 whispering-ocean systemd[1]: pm2-root.service: Start operation timed out. Terminating.
Sep 19 08:21:33 whispering-ocean systemd[1]: Failed to start PM2 process manager.
Sep 19 08:21:33 whispering-ocean systemd[1]: pm2-root.service: Unit entered failed state.
Sep 19 08:21:33 whispering-ocean systemd[1]: pm2-root.service: Failed with result 'timeout'.
sudo service pm2-austintoddj status
...outputs:
● pm2-austintoddj.service - PM2 process manager
Loaded: loaded (/etc/systemd/system/pm2-austintoddj.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2017-09-19 08:32:03 EDT; 2 days ago
Docs: https://pm2.keymetrics.io/
Main PID: 2487 (PM2 v2.7.0: God)
Tasks: 0
Memory: 1.5M
CPU: 495ms
CGroup: /system.slice/pm2-austintoddj.service
‣ 2487 PM2 v2.7.0: God Daemon (/home/austintoddj/.pm2)
Sep 19 08:32:03 whispering-ocean pm2[2645]: [PM2][ERROR] Failed to read dump file in /home/austintoddj/.pm2/dump.pm2.bak
Sep 19 08:32:03 whispering-ocean pm2[2645]: [PM2][ERROR] No processes saved; DUMP file doesn't exist
Sep 19 08:32:03 whispering-ocean pm2[2645]: ┌───────────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬─────────────┬──────────┐
Sep 19 08:32:03 whispering-ocean pm2[2645]: │ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
Sep 19 08:32:03 whispering-ocean pm2[2645]: ├───────────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼─────────────┼──────────┤
Sep 19 08:32:03 whispering-ocean pm2[2645]: │ docs.cnvs.io │ 1 │ fork │ 2546 │ online │ 0 │ 43s │ 0% │ 41.4 MB │ austintoddj │ disabled │
Sep 19 08:32:03 whispering-ocean pm2[2645]: │ toddaustin.io │ 0 │ fork │ 2506 │ online │ 0 │ 55s │ 0% │ 41.4 MB │ austintoddj │ disabled │
Sep 19 08:32:03 whispering-ocean pm2[2645]: └───────────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴─────────────┴──────────┘
Sep 19 08:32:03 whispering-ocean pm2[2645]: Use `pm2 show <id|name>` to get more details about an app
Sep 19 08:32:03 whispering-ocean systemd[1]: Started PM2 process manager.
i see it, but it isn't reading the dump file
Sep 21 12:17:44 dest-dispatch pm2[1100]: [PM2] Restoring processes located in /home/dd/.pm2/dump.pm2
Sep 21 12:17:44 dest-dispatch pm2[1100]: [PM2][ERROR] Failed to read dump file in /home/dd/.pm2/dump.pm2
Sep 21 12:17:44 dest-dispatch pm2[1100]: [PM2] Restoring processes located in /home/dd/.pm2/dump.pm2
Sep 21 12:17:44 dest-dispatch pm2[1100]: [PM2][ERROR] Failed to read dump file in /home/dd/.pm2/dump.pm2.bak
Sep 21 12:17:44 dest-dispatch pm2[1100]: [PM2][ERROR] No processes saved; DUMP file doesn't exist
Sep 21 12:17:44 dest-dispatch pm2[1100]: ┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬─────┬──────┬──────────┐
Sep 21 12:17:44 dest-dispatch pm2[1100]: │ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
Sep 21 12:17:44 dest-dispatch pm2[1100]: └──────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴─────┴──────┴──────────┘
Sep 21 12:17:44 dest-dispatch pm2[1100]: Use pm2 show <id|name>
to get more details about an app
the file exsists, if i do pm2 resurrect it starts it up
Will checkout if there is anything wrong with the code tomorrow
Any further clarification on this @vmarchaud?
Me too have this is problem
I'm having exactly the same error as described, with same log output [PM2][ERROR] Failed to read dump file ....
Me too have some problem!
os Ubuntu 16.04 After system startup pm2-web.service is active and I if I type pm2 list I see my app is working. But app not respond!!! If I type "$ sudo systemctl reload pm2-web" - all works!
For anyone still having this problem, I had a very similar problem, and #3175 seemed to fix it for me. I had two different instances of pm2 messing each other up I believe.
This is broken for me, as per instructions. Surprised it has been a year, and this is not fixed. I only have one pm2 created.
/usr/lib/node_modules/pm2/bin/pm2 -v
3.0.0
npm -v
5.6.0
node -v
v10.1.0
The file generated is this:
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=webapp
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/opt/webapp/.pm2
PIDFile=/opt/webapp/.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
I noticed that the file is copied there directly, while everything else symlinks it:
# ls -la /etc/systemd/system/
total 56
drwxr-xr-x 13 root root 4096 Jul 5 21:40 .
drwxr-xr-x 5 root root 4096 Mar 25 05:26 ..
lrwxrwxrwx 1 root root 9 Mar 25 05:24 apt-daily.service -> /dev/null
lrwxrwxrwx 1 root root 9 Mar 25 05:24 apt-daily-upgrade.service -> /dev/null
drwxr-xr-x 2 root root 4096 Mar 25 05:18 default.target.wants
drwxr-xr-x 2 root root 4096 Mar 25 05:21 final.target.wants
drwxr-xr-x 2 root root 4096 Mar 25 05:18 getty.target.wants
drwxr-xr-x 2 root root 4096 Mar 25 05:20 graphical.target.wants
lrwxrwxrwx 1 root root 38 Mar 25 05:21 iscsi.service -> /lib/systemd/system/open-iscsi.service
drwxr-xr-x 2 root root 4096 Jul 5 21:40 multi-user.target.wants
drwxr-xr-x 2 root root 4096 Mar 25 05:18 network-online.target.wants
drwxr-xr-x 2 root root 4096 Mar 25 05:21 paths.target.wants
-rw-r--r-- 1 root root 546 Jul 5 21:40 pm2-webapp.service
drwxr-xr-x 2 root root 4096 Mar 25 05:22 remote-fs.target.wants
drwxr-xr-x 2 root root 4096 Mar 25 05:22 sockets.target.wants
lrwxrwxrwx 1 root root 31 Mar 25 05:22 sshd.service -> /lib/systemd/system/ssh.service
drwxr-xr-x 2 root root 4096 Mar 25 05:31 sysinit.target.wants
lrwxrwxrwx 1 root root 35 Mar 25 05:18 syslog.service -> /lib/systemd/system/rsyslog.service
drwxr-xr-x 2 root root 4096 Mar 25 05:29 timers.target.wants
same issue here, still no fix?
This solved the problem for me:
https://stackoverflow.com/questions/34821063/pm2-startup-not-starting-up-on-ubuntu#54193188
(I think it could be more clear in the pm2 startup
instructions that pm2 start <app.js>
should be started through systemctl
)
The solution for me was restarting pm2 with systemctl: systemctl reload-or-restart pm2-root
When I setup my Ubuntu 18.04 server on the first time, I ran pm2 start app.js
to start my app. Then when I tried to run pm2 startup
+ pm2 save
to restart the app on boot, this seemed to be not working, as by running systemctl list-units
, pm2 didn’t show up in the services list. Even though the app was running (pm2 list
confirmed that). So I ran systemctl list-units -all
, and pm2 showed as “inactive” and “dead”.
So I did:
systemctl status pm2-root
(just to confirm that it was "inactive"/"dead")
systemctl reload-or-restart pm2-root
(to restart pm2 through systemctl)
systemctl status pm2-root
(to confirm that pm2 now was “active”/“running”)
Then I also ran systemctl enable pm2-root
, to enable PM2 to run on startup (not sure if necessary)
And pm2 startup
+ pm2 save
again (for the start on boot)
OBS.: I used pm2-root
in my commands, as I was running pm2 with root user, but you should replace for your user (pm2-<USER>
), if needed.
Same problem here solved by commenting out "Type=forking" on service unit.
In my case this happened after I shut down and restarted my ubuntu server. Starting/stopping/restarting pm2 was not working - I noticed that pm2 was running the script from the wrong exec cwd
. You can see this if you run pm2 show <processId>
. It should be in the same directory as your package.json containing your start script.
I ran pm2 kill
to kill off the process, then cd into the directory with your package.json and run your start command (in my case pm2 start npm -- run start
).
On my system it was returning status=205/LIMITS
, meaning that the process was exceeding the limits of my system.
I had to remove the following lines to make it work:
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Your issue may already be reported! Please search on the issue tracker before creating one.
What's going wrong?
On server reboot, pm2 is not restarting the two applications that I've got. I run my process as such:
I don't know if it has something to do with what user permissions have to be regarding pm2, but every time I reboot the server, the applications aren't running anymore and I need to run
pm2 resurrect
.How could we reproduce this issue?
Run the steps given above on a Ubuntu 16 server.
Supporting information
None
Please run the following command (available on PM2 >= 2.6)