Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Service file for running NodeBB with systemd. Drop or symlink into the /etc/systemd/system/ folder. This version uses node versions provided by nvm.
[Unit]
Description=NodeBB forum for Node.js.
Documentation=http://nodebb.readthedocs.io/en/latest/
After=system.slice multi-user.target
[Service]
Type=simple
User=nodebb
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodebb
Environment=NODE_ENV=production
Environment=HOME=/usr/share/nginx/nodebb
Environment=PATH=/usr/share/nginx/nodebb/.nvm/versions/node/v4.8.5/bin:/usr/local/bin:/usr/bin:/bin
WorkingDirectory=/usr/share/nginx/nodebb/NodeBB/
# Call with exec to be able to redirect output: http://stackoverflow.com/a/33036589/1827734
ExecStart=/bin/bash -c 'exec /usr/share/nginx/nodebb/.nvm/versions/node/v4.8.5/bin/node /usr/share/nginx/nodebb/NodeBB/loader.js --no-daemon --no-silent 2>&1 | tee -a /usr/share/nginx/nodebb/NodeBB/logs/output.log'
Restart=on-failure
[Install]
Alias=forum
WantedBy=multi-user.target
@teotikalki

This comment has been minimized.

Copy link

@teotikalki teotikalki commented Feb 7, 2019

I have a couple of questions about this:

  1. Why --no-daemon?
  2. Why not have the ExecStart call nodebb start?
  3. Should logging really be controlled by a piped execution?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment