Files
beszel/supplemental/guides/systemd.md

2.7 KiB

Installing as a Linux systemd service

This is useful if you want to run the hub or agent in the background continuously, including after a reboot.

There are two scripts, one for the hub and one for the agent. You can run either one, or both.

The install script creates a dedicated user for the service (beszel), downloads the latest release, and installs the service.

Note

You need system administrator privileges to run the install script. If you encounter a problem, please open an issue.

Hub

Download the script:

curl -sL https://raw.githubusercontent.com/henrygd/beszel/main/supplemental/scripts/install-hub.sh -o install-hub.sh && chmod +x install-hub.sh

Install

./install-hub.sh

Uninstall

./install-hub.sh -u

Update

sudo /opt/beszel/beszel update && sudo systemctl restart beszel

Agent

Download the script:

curl -sL https://raw.githubusercontent.com/henrygd/beszel/main/supplemental/scripts/install-agent.sh -o install-agent.sh && chmod +x install-agent.sh

Install

You may optionally include the SSH key and port as arguments. Run ./install-agent.sh -h for more info.

./install-agent.sh

Uninstall

./install-agent.sh -u

Update

sudo /opt/beszel-agent/beszel-agent update && sudo systemctl restart beszel-agent

Manual install

  1. Create the system service at /etc/systemd/system/beszel.service
[Unit]
Description=Beszel Hub Service
After=network.target

[Service]
# update the values in the curly braces below (remove the braces)
ExecStart={/path/to/working/directory}/beszel serve
WorkingDirectory={/path/to/working/directory}
User={YOUR_USERNAME}
Restart=always

[Install]
WantedBy=multi-user.target
  1. Start and enable the service to let it run after system boot
sudo systemctl daemon-reload
sudo systemctl enable beszel.service
sudo systemctl start beszel.service

Run the agent as a system service (Linux)

This runs the agent in the background continuously using systemd.

  1. Create the system service at /etc/systemd/system/beszel-agent.service
[Unit]
Description=Beszel Agent Service
After=network.target

[Service]
# update the values in curly braces below (remove the braces)
Environment="PORT={PASTE_YOUR_PORT_HERE}"
Environment="KEY={PASTE_YOUR_KEY_HERE}"
ExecStart={/path/to/directory}/beszel-agent
User={YOUR_USERNAME}
Restart=always

[Install]
WantedBy=multi-user.target
  1. Start and enable the service to let it run after system boot
sudo systemctl daemon-reload
sudo systemctl enable beszel-agent.service
sudo systemctl start beszel-agent.service