Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for service reload and sync service file #2102

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/packaging/headscale.systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Type=simple
User=headscale
Group=headscale
ExecStart=/usr/bin/headscale serve
ExecReload=/usr/bin/kill -HUP $MAINPID
Restart=always
RestartSec=5

Expand Down
44 changes: 8 additions & 36 deletions docs/running-headscale-linux-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
## Goal

This documentation has the goal of showing a user how-to set up and run `headscale` on Linux.
In additional to the "get up and running section", there is an optional [SystemD section](#running-headscale-in-the-background-with-systemd)
In additional to the "get up and running section", there is an optional [systemd section](#running-headscale-in-the-background-with-systemd)
describing how to make `headscale` run properly in a server environment.

## Configure and run `headscale`
Expand Down Expand Up @@ -66,7 +66,7 @@ describing how to make `headscale` run properly in a server environment.
To continue the tutorial, open a new terminal and let it run in the background.
Alternatively use terminal emulators like [tmux](https://github.com/tmux/tmux) or [screen](https://www.gnu.org/software/screen/).

To run `headscale` in the background, please follow the steps in the [SystemD section](#running-headscale-in-the-background-with-systemd) before continuing.
To run `headscale` in the background, please follow the steps in the [systemd section](#running-headscale-in-the-background-with-systemd) before continuing.

1. Verify `headscale` is running:
Verify `headscale` is available:
Expand Down Expand Up @@ -109,42 +109,14 @@ This will return a pre-authenticated key that can be used to connect a node to `
tailscale up --login-server <YOUR_HEADSCALE_URL> --authkey <YOUR_AUTH_KEY>
```

## Running `headscale` in the background with SystemD
## Running `headscale` in the background with systemd

:warning: **Deprecated**: This part is very outdated and you should use the [pre-packaged Headscale for this](./running-headscale-linux.md)

This section demonstrates how to run `headscale` as a service in the background with [SystemD](https://www.freedesktop.org/wiki/Software/systemd/).
This section demonstrates how to run `headscale` as a service in the background with [systemd](https://systemd.io/).
This should work on most modern Linux distributions.

1. Create a SystemD service configuration at `/etc/systemd/system/headscale.service` containing:

```systemd
[Unit]
Description=headscale controller
After=syslog.target
After=network.target

[Service]
Type=simple
User=headscale
Group=headscale
ExecStart=/usr/local/bin/headscale serve
Restart=always
RestartSec=5

# Optional security enhancements
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=strict
ProtectHome=yes
WorkingDirectory=/var/lib/headscale
ReadWritePaths=/var/lib/headscale /var/run/headscale
AmbientCapabilities=CAP_NET_BIND_SERVICE
RuntimeDirectory=headscale

[Install]
WantedBy=multi-user.target
```
1. Copy [headscale's systemd service file](./packaging/headscale.systemd.service) to
`/etc/systemd/system/headscale.service` and adjust it to suit your local setup. The following parameters likely need
to be modified: `ExecStart`, `WorkingDirectory`, `ReadWritePaths`.

Note that when running as the headscale user ensure that, either you add your current user to the headscale group:

Expand All @@ -164,7 +136,7 @@ This should work on most modern Linux distributions.
unix_socket: /var/run/headscale/headscale.sock
```

1. Reload SystemD to load the new configuration file:
1. Reload systemd to load the new configuration file:

```shell
systemctl daemon-reload
Expand Down
2 changes: 1 addition & 1 deletion docs/running-headscale-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Get Headscale up and running.

This includes running Headscale with SystemD.
This includes running Headscale with systemd.

## Migrating from manual install

Expand Down
2 changes: 1 addition & 1 deletion integration/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestResolveMagicDNS(t *testing.T) {
// All the containers are based on Alpine, meaning Tailscale
// will overwrite the resolv.conf file.
// On other platform, Tailscale will integrate with a dns manager
// if available (like Systemd-Resolved).
// if available (like systemd-resolved).
func TestValidateResolvConf(t *testing.T) {
IntegrationSkip(t)

Expand Down
Loading