systemd.service 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. [Unit]
  2. Description=flohmarkt server
  3. After=network.target couchdb.service
  4. [Service]
  5. Type=simple
  6. User=__APP__
  7. Group=__APP__
  8. WorkingDirectory=__FLOHMARKT_INSTALL__
  9. Environment="VENV_DIR=__FLOHMARKT_VENV_DIR__"
  10. ExecStart=/bin/bash -c "__FLOHMARKT_VENV_DIR__/bin/uvicorn --host 127.0.0.1 --port 8000 --reload flohmarkt.web:start 2>&1 | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%S'"
  11. # nicer logfile naming https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/38
  12. StandardOutput=append:/var/log/__ID__/__APP__.log
  13. StandardError=inherit
  14. # Sandboxing options to harden security
  15. # Depending on specificities of your service/app, you may need to tweak these
  16. # .. but this should be a good baseline
  17. # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
  18. NoNewPrivileges=yes
  19. PrivateTmp=yes
  20. PrivateDevices=yes
  21. RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
  22. RestrictNamespaces=yes
  23. RestrictRealtime=yes
  24. DevicePolicy=closed
  25. ProtectSystem=full
  26. ProtectControlGroups=yes
  27. ProtectKernelModules=yes
  28. ProtectKernelTunables=yes
  29. LockPersonality=yes
  30. SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
  31. # Denying access to capabilities that should not be relevant for webapps
  32. # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
  33. CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
  34. CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
  35. CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
  36. CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
  37. CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
  38. CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
  39. CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
  40. CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
  41. CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
  42. [Install]
  43. WantedBy=multi-user.target