Skip to content

SystemD

Below is an example SystemD service for running Spacebar.
Save it in /etc/systemd/system/spacebar.service.

[Unit]
Description=Spacebar, for better and secure communication

[Service]
User=<your user>
WorkingDirectory=<spacebar directory>
ExecStart=npm run start
Restart=always
StandardError=journal
StandardOutput=journal

[Install]
WantedBy=multi-user.target

Do not run Spacebar as the root user. This is a security risk to your system.

Make sure to edit the file as needed, such as replacing the user. It is a good idea to create a new user on your system to run Spacebar. If you would like to run the API, CDN or Gateway separately, you can edit the ExecStart command used in line with the npm script. Also be sure to run RabbitMQ in that case.

You can now start Spacebar using sudo systemctl start spacebar.

To automatically run Spacebar on boot, use sudo systemctl enable spacebar.

To view the server logs, you may use journalctl -u spacebar, or with -f to view them as they come.

You may also use the lnav package to get nice, colourised and scrolling output:
journalctl -xefu spacebar | lnav