Running on startup (PM2 preferably)

  • Hey everyone!

    I'm following the docs (I think they are a bit outdated in some places) and by the end of the installation it says I can start the server with a systemctl call like this:

    sudo service nodebb start

    But the service doesn't exist after the installation process. I tried using the service file provided in the docs, but the command is wrong (it needs to pass the start argument) and it doesn't work (no errors, but the server is not up).

    I'm setting it up on Digital Ocean, and I'm planning on using Nginx to manage SSL and other redirections we need to implement. On their guides, they recommend using PM2 and I actually quite like it. I managed to setup the NodeBB process using:

    pm2 start /opt/nodebb/nodebb -- start

    But using pm2 monit I can see the server constantly restarting with a SIGINT. The app is serving the page on the right port, everything is working fine, but the monitor shows that the app is constantly restarting. I tried using loader.js instead of nodebb start and it errors out after 15 restarts, and executing pm2 with -x (loader or nodebb) doesn't change anything.

    Is there a correct way of setting up NodeBB as a service, preferably using PM2?

  • You should just use app.js instead of loader or NodeBB if you're using pm2. Nobody here uses pm2 to run NodeBB because it's not very compatible with our clustering method.

  • Hi Everyone !

    @jcano : Did you have any success with pm2 ?
    I have the same exact problematic.
    I don't know how to setup nodebb to start with systemctl (we should need a nodebb.service file example)
    So i wanted to ressort to pm2 to do the job as i allready use it on the same server to watch other nodejs processes and it does a great job.

    So far i've tried all of these commands and they seem to work as expected :

    pm2 start app.js --name nodebb
    pm2 list
    pm2 restart nodebb
    pm2 stop nodebb

    But now, i don't know how to see the log (./nodebb log doesn't work anymore, or to issue commands like ./nodebb upgrade)

    @PitaJ : Is there something else to know, like env variables to setup... ?

  • pm2 should handle the logs for you. All of the nodebb commands like build, upgrade, activate, etc should still work fine.

  • @pitaj Well yes thxxs ! 👍
    It seems to work this command : pm2 logs nodebb
    I'll update this post if i encounter any unwanted behaviours with this solution !

Suggested Topics

| | | |