NodeBB logs to journalctl?
-
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?
-
@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 toExecStart
and stdout from the forked process will automatically be piped toloader.js
's stdout, which will be caught by systemd and logged to the journal.Alternatively you can maybe change
Type
tosimple
and add the--no-daemon
flag toExecStart
,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
-
@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 toExecStart
and stdout from the forked process will automatically be piped toloader.js
's stdout, which will be caught by systemd and logged to the journal.Alternatively you can maybe change
Type
tosimple
and add the--no-daemon
flag toExecStart
,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. -