Debian Codegraph @

contrib/server/nginx-systemd/[email protected]

raw
1 # Template service unit for borgstore REST server with socket activation.
2 #
3 # The instance name (%i) is the repo identifier, which must match a
4 # borgstore@%i.socket unit and an environment file in /etc/borgstore/.
5 #
6 # Deploy:
7 # cp [email protected] [email protected] /etc/systemd/system/
8 # systemctl daemon-reload
9 # systemctl enable --now [email protected]
10 #
11 # Connect (borg client, via nginx reverse proxy — see nginx-borgstore.conf):
12 # borg -r http://backup.example.com/repos/borg/repo1/ repo-create ...
13
14 [Unit]
15 Description=BorgStore REST server (%i)
16 Documentation=https://github.com/borgbackup/borgstore
17 # Start after the socket unit activates us; also restart if socket is restarted
18 Requires=borgstore@%i.socket
19 After=borgstore@%i.socket
20
21 [Service]
22 Type=simple
23 User=borgstore
24 Group=borgstore
25
26 # Credentials loaded from per-instance env file.
27 # Minimum required: BORGSTORE_BACKEND, BORGSTORE_USERNAME, BORGSTORE_PASSWORD
28 EnvironmentFile=/etc/borgstore/%i.env
29
30 # No absolute path here: systemd looks the executable up in its search path,
31 # which covers /usr/local/bin ("pip install" as root) as well as /usr/bin (a
32 # distribution package). Use an absolute path for an install in a virtualenv.
33 ExecStart=borgstore-server-rest \
34 --backend ${BORGSTORE_BACKEND} \
35 --username ${BORGSTORE_USERNAME} \
36 --password ${BORGSTORE_PASSWORD} \
37 --socket-activation
38
39 # Kill the process after 30 s of idle (no open connections).
40 # Systemd will restart it on the next connection via the socket unit.
41 # Remove these two lines if you prefer the process to stay resident.
42 TimeoutStopSec=30
43 KillMode=control-group
44
45 Restart=on-failure
46 RestartSec=5
47
48 # Harden the service
49 NoNewPrivileges=true
50 ProtectSystem=strict
51 ProtectHome=true
52 ReadWritePaths=/srv/borgstore
53 PrivateTmp=true
54 # No RuntimeDirectory=borgstore here: /run/borgstore/ is shared by the sockets
55 # of all instances, and systemd removes a runtime directory (with all the
56 # sockets in it) as soon as the one instance declaring it stops or fails.
57
58 [Install]
59 # Not enabled directly; the .socket unit triggers this.
60 WantedBy=multi-user.target