diff options
author | David Mehren | 2021-03-06 13:02:05 +0100 |
---|---|---|
committer | David Mehren | 2021-04-16 21:18:35 +0200 |
commit | c54eef10a6bc290e6b3151cfb82e867ec1759c44 (patch) | |
tree | aae24ef1c0b1ca440da17d8f76fbb272038c8d68 /docs/content | |
parent | 27d53f52330d9b1d0144075c1ae430ecce7d233b (diff) |
Add an example systemd unit to installation docs
Heavily inspired by the unit of Arch Linux:
https://github.com/archlinux/svntogit-community/blob/packages/hedgedoc/trunk/hedgedoc.service
Fixes https://github.com/hedgedoc/hedgedoc/issues/46
Signed-off-by: David Mehren <git@herrmehren.de>
Diffstat (limited to '')
-rw-r--r-- | docs/content/setup/manual-setup.md | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/docs/content/setup/manual-setup.md b/docs/content/setup/manual-setup.md index 072b2168..4c1d2675 100644 --- a/docs/content/setup/manual-setup.md +++ b/docs/content/setup/manual-setup.md @@ -28,7 +28,8 @@ ``` This way it's easier to see warnings or errors that might occur. <small>You can leave out `NODE_ENV=production` for development.</small> -7. Run the server as you like (node, forever, pm2, SystemD, Init-Scripts) +8. Run the server as you like (node, forever, pm2, systemd, Init-Scripts). + See [below](#systemd-unit-example) for an example using systemd. ## Upgrading @@ -53,3 +54,70 @@ If you are upgrading HedgeDoc from an older version, follow these steps: ``` This way it's easier to see warnings or errors that might occur. 8. You can now restart the HedgeDoc server! + +## Systemd Unit Example +Using the unit file below, you can run HedgeDoc as a systemd service. + +!!! warning + - In this example, you must configure HedgeDoc using the `config.json` file and the + `production` key. + - Make sure the user and group `hedgedoc` exists and has appropriate permissions in the + directory you installed HedgeDoc in or change the `User` and `Group` settings in the unit + file. + - Make sure `WorkingDirectory` points to the directory you installed HedgeDoc in. + - Make sure `ReadWritePaths` contains all directories HedgeDoc might write to. This may + include the `public/uploads` folder if you configured local storage. If you use SQLite, you + must also include the directory where the database file is saved. **Do not save the SQLite + file in the root directory of the HedgeDoc installation**, but create a subfolder like `db`! + - If you use an external database like PostgreSQL or MariaDB, make sure to add a corresponding + `After` statement. + +```ini +[Unit] +Description=HedgeDoc - The best platform to write and share markdown. +Documentation=https://docs.hedgedoc.org/ +After=network.target +# Uncomment if you use MariaDB/MySQL +# After=mysql.service +# Uncomment if you use PostgreSQL +# After=postgresql.service + +[Service] +Type=exec +Environment=NODE_ENV=production +Restart=always +RestartSec=2s +ExecStart=/usr/bin/yarn start --production +CapabilityBoundingSet= +NoNewPrivileges=true +PrivateDevices=true +RemoveIPC=true +LockPersonality=true +ProtectControlGroups=true +ProtectKernelTunables=true +ProtectKernelModules=true +ProtectKernelLogs=true +ProtectClock=true +ProtectHostname=true +ProtectProc=noaccess +RestrictRealtime=true +RestrictSUIDSGID=true +RestrictNamespaces=true +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 +ProtectSystem=strict +ProtectHome=true +PrivateTmp=true +SystemCallArchitectures=native +SystemCallFilter=@system-service + +# You may have to adjust these settings +User=hedgedoc +Group=hedgedoc +WorkingDirectory=/opt/hedgedoc + +# Example: local storage for uploads and SQLite +# ReadWritePaths=/opt/hedgedoc/public/uploads /opt/hedgedoc/db + +[Install] +WantedBy=multi-user.target +``` |