Start NodeBB on system boot

General Discussion
  • just put in cronjob something like this:

    @reboot cd <path>/<to>/<nodebb> && ./nodebb start

    that would do the startup trick.
    Until the latest version pm2 was doing a good job.

  • start on startup
    stop on runlevel [016]
    
    respawn
    
    setuid nodebb
    setgid nodebb
    
    script
        cd /srv/www/mywebsite/nodebb
        node loader.js --no-silent --no-daemon
    end script
    

    This script (from https://docs.nodebb.org/en/latest/running/index.html) has been working for me forever on 0.6.x but is no longer starting NodeBB on startup. /var/log/upstart/nodebb.log contains this, repeated over and over again:

    events.js:85
          throw er; // Unhandled 'error' event
                ^
    Error: EROFS, open '/opt/nodebb/logs/output.log'
        at Error (native)
    events.js:85
          throw er; // Unhandled 'error' event
                ^
    Error: EROFS, open '/opt/nodebb/logs/output.log'
        at Error (native)
    

    Anyone have a clue what might be broken?
    sudo start nodebb works as expected, as does ./nodebb start and node loader.js --no-silent --no-daemon works when I log in to the console. I replaced that line with ./nodebb start and it seems to work. Is this just a case of the docs being out of date or is this something I should be concerned about?

  • Here is what my startup script looks like on ubuntu 14.10 (my nodebb is run under my username)

  • @Shaun, the EROFS error points to /opt/nodebb not being a writable file system... as far as I know, that upstart script still works, as I am using it myself.

  • @julian But that's not really possible. I can start it under my user account, even using the same command and it starts from the startup script after I changed it to ./nodebb start ... and it was working for months before I upgraded to 0.7.2 and just suddenly stopped because of it. And starting it from any other method does write output to /opt/nodebb/logs/output.log:

    [email protected]:/opt/nodebb/logs$ ls -la
    total 20
    drwxrwxr-x  2 nodebb nodebb 4096 Aug  4 06:55 .
    drwxr-xr-x 10 nodebb nodebb 4096 Aug  4 07:28 ..
    -rw-rw-r--  1 nodebb nodebb 6 Aug  4 06:51 .gitignore
    -rw-rw-r--  1 nodebb nodebb 5021 Aug  4 07:28 output.log
    

    I ran into so many problems after this upgrade that I just threw the whole instance away (mv /opt/nodebb /opt/nodebb_old) made a new directory and installed using the steps from https://docs.nodebb.org/en/latest/installing/os/ubuntu.html starting with the repository clone:

    git clone -b v0.7.x https://github.com/NodeBB/NodeBB.git nodebb
    cd nodebb
    npm install --production
    ./nodebb setup
    

    I ended up copying the old config.json file back into the new directory because I was too lazy to copy and paste the secret, but I am otherwise now running a brand spankin' new install of v0.7.2 and I hit the same problem. same EROFS error in /var/log/upstart/nodebb.log after I put the old /etc/init/nodebb.conf back.

    I also have a minor problem with the persona theme (.taskbar CSS class has a width of 50% specified in stylesheet.css even after updating the theme to the latest from the ACP), a plugin that completely breaks the service whenever a topic is loaded (nodebb-plugin-topic-badges) and a plugin that tries to turn every link that starts with http:// into a YouTube embed (nodebb-plugin-youtube-lite).

    The clean install did fix a problem I was having with the chat windows.

    Nevermind. Updating the theme in the ACP broke the chat windows again, so that's the problem with that one.

  • Does the error still occur if you delete output.log before starting NodeBB?

  • @julian deleted log file, rebooted, same error and log file does not exist.

    Manual ./nodebb start creates log file.
    Manual node loader.js --no-silent --no-daemon also creates log file.

    It just wont do it from upstart for some reason.

    Edit: Doesn't work even with chmod 777 on the output.log file and the containing directory. Really doesn't make any sense to me. Though on further consideration, it might have been broken by a package update from apt-get and I just didn't notice because I hadn't rebooted in a while.

  • @Shaun Yeah, I really am at a loss for what's happening here, as I've never run into it.

    Did you resolve the problem?

  • @julian No. Not really sure what else I can do except to maybe rebuild the whole server. I'm just running the upstart script with ./nodebb start for now. IIRC, the major drawback to that was that it doesn't write the PID to a file and so you can't make an orderly stop to the process, which is not ideal, but it will work for me for now.

  • This post is deleted!


Suggested Topics