feat: adjust doc/pm2.md

This commit is contained in:
dancingCycle 2024-04-10 12:49:16 +02:00
parent 485d136532
commit 37e5249974
1 changed files with 19 additions and 15 deletions

View File

@ -1,25 +1,21 @@
# Setup pm2
* configure pm2 like [this](https://pm2.io/docs/runtime/guide/installation/) to start API on system startup
//OPTION: * with npm
```
npm install pm2 -g
apt update && apt install sudo curl && curl -sL https://raw.githubusercontent.com/Unitech/pm2/master/packager/setup.deb.sh | sudo -E bash -
```
//OPTION: * with GNU/Debian
```
sudo apt update && sudo apt install sudo curl && curl -sL https://raw.githubusercontent.com/Unitech/pm2/master/packager/setup.deb.sh | sudo -E bash -
```
* logout and login in again to make the instructions above available
```
exit
ssh api-data.vbn.de@srv-web-01.vbn-gmbh.local
```
* install pm2 autocompletion
```
pm2 completion install
```
* Update pm2
```
npm install pm2 -g && pm2 update
ssh <user>@<host>
```
* verify installation of pm2
@ -30,11 +26,19 @@ pm2 --version
* initialize pm2 as a startup service
```
pm2 startup
//ON-DEMAND: sudo env PATH=$PATH:/home/api-data.vbn.de/.nvm/versions/node/v18.17.1/bin /home/api-data.vbn.de/.nvm/versions/node/v18.17.1/lib/node_modules/pm2/bin/pm2 startup systemd -u api-data.vbn.de --hp <enter path>
```
* to setup the Startup Script, copy/paste the following command:
# Options
* update pm2 with npm
```
sudo env PATH=$PATH:/home/api-data.vbn.de/.nvm/versions/node/v18.17.1/bin /home/api-data.vbn.de/.nvm/versions/node/v18.17.1/lib/node_modules/pm2/bin/pm2 startup systemd -u api-data.vbn.de --hp /home/api-data.vbn.de
npm install pm2 -g && pm2 update
```
* install pm2 autocompletion
```
pm2 completion install
```
* start the service as npm start script with PM2
@ -49,7 +53,7 @@ pm2 start --name api-data.vbn.de npm -- start --watch
pm2 save
```
* OPTION: restart/logout/login your system, and check if all the serviceis running under PM2
* restart/logout/login your system, and check if all the serviceis running under PM2
```
pm2 ls
```