Pm2: Startup script does not work (errored status)

Created on 22 Mar 2016  ยท  2Comments  ยท  Source: Unitech/pm2

I installed pm2 in Vagrant using the latest ubunty/trusty64 box. I installed NodeJS v4.4.0 and NPM 2.14.20 using NVM. I use pm2 version 1.0.2.

I have 5 node scripts running in fork mode. I originally started them using

pm2 start --name [service_name] [path_to_script]

I then saved the configuration using:

pm2 save

And next I generated the startup script:

sudo pm2 startup ubuntu -u vagrant

I see the following output:

[PM2] Generating system init script in /etc/init.d/pm2-init.sh
[PM2] Making script booting at startup...
[PM2] -ubuntu- Using the command:
      su -c "chmod +x /etc/init.d/pm2-init.sh && update-rc.d pm2-init.sh defaults"
 Adding system startup for /etc/init.d/pm2-init.sh ...
   /etc/rc0.d/K20pm2-init.sh -> ../init.d/pm2-init.sh
   /etc/rc1.d/K20pm2-init.sh -> ../init.d/pm2-init.sh
   /etc/rc6.d/K20pm2-init.sh -> ../init.d/pm2-init.sh
   /etc/rc2.d/S20pm2-init.sh -> ../init.d/pm2-init.sh
   /etc/rc3.d/S20pm2-init.sh -> ../init.d/pm2-init.sh
   /etc/rc4.d/S20pm2-init.sh -> ../init.d/pm2-init.sh
   /etc/rc5.d/S20pm2-init.sh -> ../init.d/pm2-init.sh
[PM2] Done.

At this point all scripts run properly.

Next when I reboot the VM and use pm2 list I see the following output:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ App name        โ”‚ id โ”‚ mode โ”‚ pid โ”‚ status  โ”‚ restart โ”‚ uptime โ”‚ memory โ”‚ watching โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ movindev_data   โ”‚ 0  โ”‚ fork โ”‚ N/A โ”‚ errored โ”‚ 0       โ”‚ 0      โ”‚ 0 B    โ”‚ disabled โ”‚
โ”‚ movindev_wmts   โ”‚ 1  โ”‚ fork โ”‚ N/A โ”‚ errored โ”‚ 0       โ”‚ 0      โ”‚ 0 B    โ”‚ disabled โ”‚
โ”‚ movindev_wrs    โ”‚ 2  โ”‚ fork โ”‚ N/A โ”‚ errored โ”‚ 0       โ”‚ 0      โ”‚ 0 B    โ”‚ disabled โ”‚
โ”‚ movindev_was    โ”‚ 3  โ”‚ fork โ”‚ N/A โ”‚ errored โ”‚ 0       โ”‚ 0      โ”‚ 0 B    โ”‚ disabled โ”‚
โ”‚ movindev_portal โ”‚ 4  โ”‚ fork โ”‚ N/A โ”‚ errored โ”‚ 0       โ”‚ 0      โ”‚ 0 B    โ”‚ disabled โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

As you can see all nodejs processes quit with an errored state. Viewing the logs at /home/vagrant/.pm2/pm2.log shows the following exception:

2016-03-22 14:02:49: Error: spawn node ENOENT
    at exports._errnoException (util.js:870:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickDomainCallback (node.js:397:17)

Interestingly enough when I do pm2 restart all all scripts start properly. This only goes wrong after a reboot.

Does anyone know what I can do to fix this?

Most helpful comment

I faced issue like this also.
This issue related to the vagrant folder mounting.

I prefer use provision:
https://www.vagrantup.com/docs/cli/provision.html

config.vm.provision "shell", path: "your_script_path_in_your_localmachine", run: "always", privileged: true

it works for me.

All 2 comments

I faced issue like this also.
This issue related to the vagrant folder mounting.

I prefer use provision:
https://www.vagrantup.com/docs/cli/provision.html

config.vm.provision "shell", path: "your_script_path_in_your_localmachine", run: "always", privileged: true

it works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ldarren picture ldarren  ยท  3Comments

rajendar38 picture rajendar38  ยท  3Comments

cchan picture cchan  ยท  3Comments

phra picture phra  ยท  3Comments

getvega picture getvega  ยท  3Comments