Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bdharrington7
Last active February 7, 2019 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdharrington7/2599927d41d30f11900f2099b8d8fc64 to your computer and use it in GitHub Desktop.
Save bdharrington7/2599927d41d30f11900f2099b8d8fc64 to your computer and use it in GitHub Desktop.
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
Copy link

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