Unitech / pm2

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

pm2 is been installed twice! #3642

Closed llioor closed 6 years ago

llioor commented 6 years ago

I searched for a solution online but it looks like only I have this issue! I installed pm2 on Ubuntu 16.04 I need to run pm2 as ubuntu user but I have 2 installations of pm2:

ps -ef | grep pm2
root      1300     1  0 15:19 ?        00:00:00 PM2 v2.10.3: God Daemon (/root/.pm2)
ubuntu    1301     1  0 15:19 ?        00:00:00 PM2 v2.10.3: God Daemon (/home/ubuntu/.pm2)

Even when I remove the folders, remove any memory of pm2 (which pm2)... uninstall node and npm and reinstall it still install pm2 in 2 locations.

This is how I install node: (current user is ubuntu)

cd ~
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh 
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
sudo apt-get install build-essential

This is how I install pm2: (current user is ubuntu)

sudo npm install -g pm2
cd <my php artisan project folder>
pm2 start pm2.json
pm2 list # (show the process under ubuntu)
pm2 startup
sudo ********
pm2 save

Then I run ps -ef | pm2 and I have the same results.

Unitech commented 6 years ago

Can you show me the content of the startup script? (cat /etc/systemd/system/pm2*)

llioor commented 6 years ago

[Unit] Description=PM2 process manager Documentation=https://pm2.keymetrics.io/ After=network.target

[Service] Type=forking User=root LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/ Environment=PM2_HOME=/root/.pm2 PIDFile=/root/.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 [Unit] Description=PM2 process manager Documentation=https://pm2.keymetrics.io/ After=network.target

[Service] Type=forking User=ubuntu LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/ 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

Unitech commented 6 years ago

Mmm there are two init script here. One for root and one for ubuntu.

If you want to keep only the pm2 running under ubuntu type the following: sudo pm2 unstartup