speedtest-go/systemd
Tim Small c67b8ec91d
Support systemd socket activation (#35)
* Support systemd socket activation

If the process has been started with systemd socket activation
configured, then serve requests on the passed-in socket instead of
attempting to bind to an address.

* Add example systemd unit files.

Add example systemd unit files which make use of systemd's security
facilities, and also allow binding to port 80 whilst running as an
unpriviliged process (using systemd socket activation).
2022-01-18 15:47:32 +08:00
..
README.md Support systemd socket activation (#35) 2022-01-18 15:47:32 +08:00
speedtest-settings.toml Support systemd socket activation (#35) 2022-01-18 15:47:32 +08:00
speedtest.service Support systemd socket activation (#35) 2022-01-18 15:47:32 +08:00
speedtest.socket Support systemd socket activation (#35) 2022-01-18 15:47:32 +08:00

Example systemd unit files

To use these, first review the speedtest.* unit files, and then:

cp ../speedtest /usr/local/bin/
mkdir -p /usr/local/share/speedtest /usr/local/etc
cp -aR ../web/assets /usr/local/share/speedtest/assets
cp speedtest-settings.toml /usr/local/etc
cp speedtest.* /etc/systemd/system/
systemctl daemon-reload

If you wish to use the bolt database type:

# Create static system user and group
adduser --system --group --no-create-home --disabled-password speedtest
mkdir -p /usr/local/var/speedtest
touch /usr/local/var/speedtest/speedtest.db
chown speedtest. /usr/local/var/speedtest/speedtest.db

To start (and enable at boot-up):

systemctl enable --now speedtest.socket

speedtest-go should now be listening for http request on port 80 on the local machine.

You will need to customise the html files e.g. edit /usr/local/share/speedtest/assets/index.html to suit your site.