• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.1 Latest
Buy Hosting

NodeBB logs to journalctl?

Scheduled Pinned Locked Moved Solved Technical Support
systemdnodebblog
5 Posts 2 Posters 344 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • rongcuidR Offline
    rongcuidR Offline
    rongcuid
    wrote on last edited by
    #1

    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?

    julianJ 2 Replies Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to rongcuid on last edited by julian
    #3

    @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.

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to rongcuid on last edited by
    #2

    @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 😄

    1 Reply Last reply
    1
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to rongcuid on last edited by julian
    #3

    @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.

    1 Reply Last reply
    0
  • rongcuidR Offline
    rongcuidR Offline
    rongcuid
    wrote on last edited by
    #4

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

    1 Reply Last reply
    2
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #5

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

    1 Reply Last reply
    0
  • julianJ julian has marked this topic as solved on

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development