Learn about Centmin Mod LEMP Stack today
Become a Member

Sysadmin Startup init script or any other solution

Discussion in 'System Administration' started by pamamolf, May 1, 2017.

  1. pamamolf

    pamamolf Well-Known Member

    2,487
    229
    63
    May 31, 2014
    Ratings:
    +390
    Local Time:
    12:59 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    Hello

    I have an addon that recommends to use "forever" to start the js script like:

    Code:
    forever start /path/to/file.js
    As if it crashes or stops running for whatever reason, forever will start it back up.

    I can run it without "forever" also using:

    Code:
    node /path/to/file.js
    Now i need some help to start up node when server is restarted (nodejs.sh does that already?) and for an automated way to start file.js using "forever" or "screen" maybe or none of them and just start it.

    Thank you
     
  2. pamamolf

    pamamolf Well-Known Member

    2,487
    229
    63
    May 31, 2014
    Ratings:
    +390
    Local Time:
    12:59 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    I was thinking for scenario one that the node is already auto starting to use a cron job like:

    Code:
    @reboot /usr/bin/forever start /path/to/file.js
    or if the installation script nodejs.sh doesn't take care of startup after server reboot to use this one?

    Code:
    @reboot /usr/bin/forever start -c /usr/bin/node /path/to/file.js
    what do you think?