starting nodebb with systemd



  • I recently moved up to Ubuntu 16.04.1. I see a nice example of Upstart in the documentation, but nothing for a systemd script.

    Does anyone have an example script I can use to manage the NodeBB service, have it start at boot, etc?


  • Global Moderator



  • @PitaJ said in starting nodebb with systemd:

    @teh_g this should be helpful: http://unix.stackexchange.com/a/47715

    In Upstart I was using node loader.js --no-silent --no-daemon, should I use that same command for the ExecStart= parameter?


  • Global Moderator

    @teh_g try it


  • Swedes

    This is what i do when running my docker pkg in systemd with nodebb (app.js)

    [Service]
    ExecStart=/usr/bin/docker run --entrypoint su --name nodejs-nimbus-jenkler-com --net local --volumes-from server_nodejs -w /server/nodejs jenkler/nodejs nobody -s /usr/bin/node app.js
    ExecStartPre=-/usr/bin/docker kill nodejs-nimbus-jenkler-com
    ExecStartPre=-/usr/bin/docker rm nodejs-nimbus-jenkler-com
    ExecStartPre=/usr/bin/sleep 10
    ExecStop=/usr/bin/docker stop nodejs-nimbus-jenkler-com
    Restart=on-failure
    RestartSec=120s
    TimeoutStartSec=0

    I start /usr/bin/node app.js as the nobody user! If somebody else runs nodebb in docker with another take, plz speak up. The app.js way works fine for me except for restarting via the webb ui. I guss i need loader.js for that :)

    Note

    If i use loader.js instead of app.js the application wont exit correctly when systemd runs ExecStop. I get some strange exit code and docker get an error. I guess thats because loader is a wrapper for app.js! Correct me if I am wrong!

    To answer the question run:

    ExecStart=/usr/bin/node app.js
    

    I guess you need to change dir also. I do that with docker -w /server/nodejs jenkler/nodejs.


  • Admin

    You pass in --no-daemon and --no-silent because Upstart works best if the program itself is run interactively, with output sent to stdout.

    However, I don't recall if systemd is different...

    If it works best run interactively, use --no-daemon.

    If it reads output from stdout (which I believe it does), then use --no-silent.


Log in to reply
 


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