Systemd

The Takeout server supports the following systemd features:

  • Systemd notify
  • Watchdog notify

A complete takeout.service file is provided in the source repository.

Service Options

The following systemd service options are used to provide configuration defaults when running with systemd. (Takeout checks for the presence of the corresponding environments being defined)

Name Description
CacheDirectory Used for image and http caches
ConfigDirectory Checked first for takeout.yaml
RuntimeDirectory Used for local sockets
StateDirectory Checked second for takeout.yaml
Working directory for server.

Example Configuration

Here is an example Takeout configuration based on the systemd configuration below.

Configuration Value
Server.DataDir /var/lib/takeout
Server.MediaDir /var/lib/takeout
Server.ImageClient.CacheDir /var/cache/takeout/imageclient
Client.CacheDir /var/cache/takeout/httpclient
Local socket /run/takeout/takeout.sock
Server config /etc/takeout
/var/lib/takeout
Media config /var/lib/takeout/{mediaName}
[Unit]
Description=TakeoutFM server
Documentation=https://takeoutfm.com/docs/server/
After=network.target

[Service]
ExecStart=/usr/bin/takeout
User=takeout

RuntimeDirectory=takeout
StateDirectory=takeout
CacheDirectory=takeout
LogsDirectory=takeout

Type=notify
WatchdogSec=60s
WatchdogSignal=SIGKILL

Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Other options to consider are below. See freedesktop.org for further information.

LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
PrivateDevices=yes
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=yes
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectSystem=yes
RestrictNamespaces=yes
RestrictRealtime=yes
SystemCallArchitectures=native

Systemd commands

# install service
$ sudo cp takeout.service /etc/systemd/system

# edit service config
$ sudo systemctl edit --full takeout

# enable service
$ sudo systemctl enable takeout

# disable service
$ sudo systemctl disable takeout

# restart takeout
$ sudo systemctl restart takeout

# start takeout
$ systemctl start takeout

# stop takeout
$ sudo systemctl stop takeout

# follow the service log
$ journalctl -f -u takeout.service

# more detailed service logs with pager
$ journalctl -xeu takeout.service