• ⚠️ Maintenance will be performed on the forums for the next couple of days. Expect some downtime. πŸ”§

MD@Home - Use PM2 As Manager

Joined
Feb 19, 2019
Messages
13
Long story short, I have developed in NodeJS for a few years and love PM2 for managing applications. So I set out to get it to work with MD@H.

1) I recommend getting a VPS from sdbx.moe or kimsufi (if you can). Zero issues so far and previous cheap hosts never worked.
-- Once you have your server. I am already assuming you know how to use SSH (mRemoteNG, Termius or Putty),

2) Make sure everything is up to date
Code:
sudo apt update; sudo apt update -y; sudo apt dist-upgrade -y

3) Install dependencies
Code:
sudo apt install -y build-essential git curl default-jre

4) Install node
Code:
sudo curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh; sudo bash nodesource_setup.sh; sudo apt install nodejs -y

5) Install PM2 and Logrotate
Code:
npm i -g pm2; pm2 install pm2-logrotate

6) Configure logrotate
Code:
pm2 set pm2-logrotate:max_size 100M
pm2 set pm2-logrotate:compress true
pm2 set pm2-logrotate:rotateInterval '* */1 * * *'
pm2 set pm2-logrotate:retain 10
max_size - Change this to whatever you want. M = Megabytes, G = Gigabytes, etc
compress - Highly recommend having it on. Otherwise change to false
roateInterval - Every hour but change to whatever. It uses cron format
retain - Change to what you want. I personally keep 10.

7) Make a directory where you want to keep MD@H and download.
Code:
mkdir -p ~/manga/{log,logs}; cd ~/manga
curl https://gitlab.com/mangadex-pub/mangadex_at_home/-/jobs/681534385/artifacts/raw/mangadex_at_home-1.2.1-all.jar -o mangadex_at_home-1.2.1-all.jar
OR
curl https://mangadex.org/dl/mangadex_at_home-1.1.5-all.jar -o mangadex_at_home-1.1.5-all.jar
curl https://mangadex.org/dl/settings.json -o settings.json

8) Change settings in settings.json to what you want.
9) Setting up PM2 process.json
Here is a sample - LINK

Example
Code:
{
    "apps": [{
            "name": "Client 1337",
            "cwd": "/home/ubuntu/manga/",
            "args": [
                "-Dfile-level=trace -Dstdout-level=info -Duser.dir=/home/ubuntu/manga",
                "-jar",
                "/home/ubuntu/manga/mangadex_at_home-1.2.1-all.jar",
                "--settings=/home/ubuntu/manga/settings.json"
            ],
            "script": "/usr/bin/java",
            "node_args": [],
            "log_date_format": "YYYY-MM-DD HH:mm Z",
            "exec_interpreter": "none",
            "exec_mode": "fork",
            "error_file": "/home/ubuntu/manga/logs/client_1337_error.log",
            "out_file": "/home/ubuntu/manga/logs/client_1337_out.log",
            "merge_logs": true,
            "instances" : 1,
            "watch": false
        }
    ]
}

10) Hopefully nothing blows up
Code:
cd ~/manga; pm2 start process.json

And if it works
Code:
β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ id  β”‚ name             β”‚ namespace   β”‚ version β”‚ mode    β”‚ pid      β”‚ uptime β”‚ β†Ί    β”‚ status    β”‚ cpu      β”‚ mem      β”‚ user     β”‚ watching β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 2   β”‚ Client 999       β”‚ default     β”‚ N/A     β”‚ fork    β”‚ 13550    β”‚ 3h     β”‚ 0    β”‚ online    β”‚ 0%       β”‚ 338.8mb  β”‚ root     β”‚ disabled β”‚
β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Module
β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ id β”‚ module                                β”‚ version            β”‚ pid   β”‚ status   β”‚ β†Ί    β”‚ cpu      β”‚ mem      β”‚ user     β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0  β”‚ pm2-logrotate                         β”‚ 2.7.0              β”‚ 12854 β”‚ online   β”‚ 4    β”‚ 0%       β”‚ 42.8mb   β”‚ root     β”‚
β””β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

11) To see what its doing
Code:
#pm2 logs id
pm2 logs 2

12) To view/stop/start it
Code:
pm2 ls - Gets list
pm2 stop id - Replace ID with pm2 ID
pm2 start id - Replace ID with pm2 ID
 
Seeing this posted in General instead of a more Technical subforum (Support/Bugs, I dunno?) feels wrong.

WTFamireading.jpg
 
Also, really nothing else fits (category wise). Do you mind contributing this to our wiki on GitLab?
 
Don't mind me, i'm just here to ask @justforthelulz for the source, if he is so kind, of course.

Thanks, now i only have 29 tabs open, wait, the number increased?!
 

Users who are viewing this thread

Back
Top