service.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package gen
  2. import (
  3. . "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/common"
  4. )
  5. var ServiceTemplate = `
  6. [Unit]
  7. Description=Gojus
  8. Documentation=https://gojus.com.br
  9. After=network-online.target
  10. Wants=network-online.target systemd-networkd-wait-online.service
  11. [Service]
  12. #Restart=on-failure
  13. #StartLimitInterval=86400
  14. #StartLimitBurst=5
  15. ; User and group the process will run as.
  16. #User=www-data
  17. #Group=www-data
  18. User=root
  19. Group=root
  20. ; Letsencrypt-issued certificates will be written to this directory.
  21. ;Environment="GOOGLE_APPLICATION_CREDENTIALS=/apps/sys/gojus/ky.json" GOOGLE_CLOUD_PROJECT=173520589311
  22. ; Always set "-root" to something safe in case it gets forgotten in the Caddyfile.
  23. ExecStart=/apps/sys/gojus/main -config=/apps/sys/gojus/config.production.json
  24. ExecReload=/bin/kill -USR1 $MAINPID
  25. #RootDirectory=/apps/sys/gojus
  26. WorkingDirectory=/apps/sys/gojus
  27. ; Limit the number of file descriptors; see "man systemd.exec" for more limit settings.
  28. LimitNOFILE=1048576
  29. ; Unmodified caddy is not expected to use more than that.
  30. LimitNPROC=64
  31. ; Use private /tmp and /var/tmp, which are discarded after caddy stops.
  32. PrivateTmp=true
  33. ; Use a minimal /dev
  34. PrivateDevices=true
  35. ; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys.
  36. ProtectHome=true
  37. ; Make /usr, /boot, /etc and possibly some more folders read-only.
  38. ProtectSystem=full
  39. ; … except /etc/ssl/caddy, because we want Letsencrypt-certificates there.
  40. ; This merely retains r/w access rights, it does not add any new. Must still be writable on the host!
  41. ReadWriteDirectories=/apps/sys/gojus
  42. ; The following additional security directives only work with systemd v229 or later.
  43. ; They further retrict privileges that can be gained by caddy. Uncomment if you like.
  44. ; Note that you may have to add capabilities required by any plugins in use.
  45. ;CapabilityBoundingSet=CAP_NET_BIND_SERVICE
  46. AmbientCapabilities=CAP_NET_BIND_SERVICE
  47. ;NoNewPrivileges=true
  48. [Install]
  49. WantedBy=multi-user.target
  50. `
  51. func CreateServiceFile(project *Project) {
  52. }