• I am starting NodeBB with systemd:

    [Unit]
    Description=NodeBB
    Documentation=https://docs.nodebb.org
    After=system.slice multi-user.target postgresql.service redis-server.service
    
    [Service]
    Type=forking
    User=nodebb
    
    WorkingDirectory=/opt/nodebb
    PIDFile=/opt/nodebb/pidfile
    Environment=NODE_ENV=production
    ExecStart=/usr/bin/env node loader.js
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    

    However, no useful logs are in journalctl. I still have to use ./nodebb log:

    $ journalctl -u nodebb -f
    Sep 25 11:13:04 home systemd[1]: Starting NodeBB...
    Sep 25 11:13:05 home systemd[1]: nodebb.service: Can't open PID file /opt/nodebb/pidfile (yet?) after start: Operation not permitted
    Sep 25 11:13:05 home systemd[1]: Started NodeBB.
    Sep 25 11:17:52 home systemd[1]: Stopping NodeBB...
    Sep 25 11:17:52 home systemd[1]: nodebb.service: Deactivated successfully.
    Sep 25 11:17:52 home systemd[1]: Stopped NodeBB.
    Sep 25 11:17:52 home systemd[1]: nodebb.service: Consumed 19.344s CPU time.
    Sep 25 11:20:19 home systemd[1]: Starting NodeBB...
    Sep 25 11:20:20 home systemd[1]: nodebb.service: Can't open PID file /opt/nodebb/pidfile (yet?) after start: Operation not permitted
    Sep 25 11:20:21 home systemd[1]: Started NodeBB.
    

    Any idea how to fix it?

  • GNU/Linux Admin

    @rongcuid I'm back!

    I've updated the default systemd config in our docs. In your specific case, all you'll have to add is the --no-silent flag to ExecStart and stdout from the forked process will automatically be piped to loader.js's stdout, which will be caught by systemd and logged to the journal.

    Alternatively you can maybe change Type to simple and add the --no-daemon flag to ExecStart, but I have not tried this and do not know whether it will work with a multi-port setup (update: I tried it, it works fine). That is how the old Upstart config worked, though, since Upstart had no support for forking processes.


  • @rongcuid Ah, I swear this used to work. Some time ago I updated all of our internal servers from 16.04 to 22.04 and then all of our systemd services stopped sending logs to the journal 😢

    Not too big a loss, I think the systemctl journal's dumb, but I do recognize that people use it and want it to work well.

    Let me research a bit and see what I find 😄

  • GNU/Linux Admin

    @rongcuid I'm back!

    I've updated the default systemd config in our docs. In your specific case, all you'll have to add is the --no-silent flag to ExecStart and stdout from the forked process will automatically be piped to loader.js's stdout, which will be caught by systemd and logged to the journal.

    Alternatively you can maybe change Type to simple and add the --no-daemon flag to ExecStart, but I have not tried this and do not know whether it will work with a multi-port setup (update: I tried it, it works fine). That is how the old Upstart config worked, though, since Upstart had no support for forking processes.


  • Late reply, but I used the updated service file and it works.

  • GNU/Linux Admin

    Hooray! Thanks for coming back and confirming the new file works for you 😄

  • Topic has been marked as solved   julianJ   julian 

Suggested Topics

| | | |