pyrtan / deploy / systemd / pyrtan-demo.service
1,168 bytes · last changed 2026-10-25 in Initial public release
| 1 | # Pyrtan demo as one systemd service, without Docker: a single process |
| 2 | # holding every example tree, serving the demo page on port 8701. |
| 3 | # |
| 4 | # sudo cp pyrtan-demo.service /etc/systemd/system/ |
| 5 | # sudo systemctl daemon-reload && sudo systemctl enable --now pyrtan-demo |
| 6 | # |
| 7 | # Assumes pyrtan was installed under /opt/pyrtan as deploy/README.md |
| 8 | # describes, so the command lives at /opt/pyrtan/bin/pyrtan. Trees are read |
| 9 | # from /var/lib/pyrtan/trees; edit TREES to taste. |
| 10 | |
| 11 | [Unit] |
| 12 | Description=Pyrtan demo swarm (single process) |
| 13 | After=network-online.target |
| 14 | Wants=network-online.target |
| 15 | |
| 16 | [Service] |
| 17 | Type=simple |
| 18 | User=pyrtan |
| 19 | Group=pyrtan |
| 20 | Environment=PYTHONUNBUFFERED=1 |
| 21 | Environment=TREES=/var/lib/pyrtan/trees |
| 22 | ExecStart=/opt/pyrtan/bin/pyrtan serve ${TREES} --host 0.0.0.0 --port 8701 --name demo |
| 23 | Restart=on-failure |
| 24 | RestartSec=3 |
| 25 | # Hardening: the process needs the network and read access to its trees, nothing else. |
| 26 | NoNewPrivileges=true |
| 27 | ProtectSystem=strict |
| 28 | ProtectHome=true |
| 29 | ReadOnlyPaths=/opt/pyrtan /var/lib/pyrtan |
| 30 | PrivateTmp=true |
| 31 | ProtectKernelTunables=true |
| 32 | ProtectControlGroups=true |
| 33 | RestrictSUIDSGID=true |
| 34 | LockPersonality=true |
| 35 | MemoryMax=256M |
| 36 | |
| 37 | [Install] |
| 38 | WantedBy=multi-user.target |