Welcome to the PufferPanel community forums! If you need help please register an account and post in the Support category.

Scales Better Daemon with PM2



  • PM2 will auto restart your scrip when it fails and start it upon boot. Hers how to use it with Scales:

    The first step is to edit the index.js file remove line 108 and lines 41 to 51 this will remove the existing daemon inside Scales

    These lines should be removed:
    lines 41 to 51:
    var wait = function () {
        if (readyForDaemon()) {
            if (!cliArgs.nodaemon) {
                Logger.info('Scales has started');
                require('daemon')();
                Fs.writeFileSync(pidFilePath, process.pid);
            }
        } else {
            setTimeout(wait, 500);
        }
    };
    
    line 108 : 
    wait();
    

    Next is to globally install PM2

    sudo npm install pm2 -g
    

    next you want to navigate to the directory you scales is located in

    cd /srv/scales
    

    now start scales

    pm2 start index.js
    

    and lastly add pm2 to the start up of your machine

    pm2 startup ubuntu
    

    Other commands for PM2
    pm2 start index - Start an application with this command
    pm2 stop index - Stop an application with this command
    pm2 restart index - Restart an application with this command
    pm2 list - The list of applications currently managed by PM2
    pm2 info index - More information about a specific application
    pm2 monit - This displays the application status, CPU, and memory usage

    For more information on PM2 go here!


Log in to reply
 

3
Online

666
Users

708
Topics

3.2k
Posts

Looks like your connection to PufferPanel Community was lost, please wait while we try to reconnect.