Diff
1diff --git a/README.md b/README.md
2index 54abb9e0a58c3ab89861f84801f28a543d82d04f..bff43f38c7bf3a7e6005ce1870761c85f09fa872 100644
3--- a/README.md
4+++ b/README.md
5@@ -113,6 +113,12 @@ full privileges.
6 Using this environment variable, Soft Serve will create a new `admin` user that
7 has full privileges. You can rename and change the user settings later.
8
9+Check out [Systemd][systemd] on how to run Soft Serve as a service using
10+Systemd. Soft Serve packages in our Apt/Yum repositories come with Systemd
11+service units.
12+
13+[systemd]: https://github.com/charmbracelet/soft-serve/blob/main/systemd.md
14+
15 ### Server Settings
16
17 Once you start the server for the first time, the settings will be in
18@@ -188,11 +194,9 @@ http:
19 stats:
20 # The address on which the stats server will listen.
21 listen_addr: ":23233"
22-
23 # Additional admin keys.
24 #initial_admin_keys:
25 # - "ssh-rsa AAAAB3NzaC1yc2..."
26-
27 ```
28
29 You can also use environment variables, to override these settings. All server
30diff --git a/systemd.md b/systemd.md
31new file mode 100644
32index 0000000000000000000000000000000000000000..4f436adcaa2c74215cc512c2fb32c441b62b73fa
33--- /dev/null
34+++ b/systemd.md
35@@ -0,0 +1,99 @@
36+# Running Soft Serve as a Systemd Service
37+
38+Most Linux OSes use Systemd as an init system and service management. You can
39+use Systemd to manage Soft Serve as a service on your host machine.
40+
41+Our Soft Serve deb/rpm packages come with Systemd service files pre-packaged.
42+You can install `soft-serve` from our Apt/Yum repositories. Follow the
43+[installation instructions](https://github.com/charmbracelet/soft-serve#installation) for
44+more information.
45+
46+## Writing a Systemd Service File
47+
48+> **Note** you can skip this section if you are using our deb/rpm packages or
49+> installed Soft Serve from our Apt/Yum repositories.
50+
51+Start by writing a Systemd service file to define how your Soft Serve server
52+should start.
53+
54+First, we need to specify where the data should live for our server. Here I
55+will be choosing `/var/local/lib/soft-serve` to store the server's data. Soft
56+Serve will look for this path in the `SOFT_SERVE_DATA_PATH` environment
57+variable.
58+
59+Make sure this directory exists before proceeding.
60+
61+```sh
62+sudo mkdir -p /var/local/lib/soft-serve
63+```
64+
65+We will also create a `/etc/soft-serve.conf` file for any extra server settings that we want to override.
66+
67+```conf
68+# Config defined here will override the config in /var/local/lib/soft-serve/config.yaml
69+# Keys defined in `SOFT_SERVE_INITIAL_ADMIN_KEYS` will be merged with
70+# the `initial_admin_keys` from /var/local/lib/soft-serve/config.yaml.
71+#
72+#SOFT_SERVE_GIT_LISTEN_ADDR=:9418
73+#SOFT_SERVE_HTTP_LISTEN_ADDR=:23232
74+#SOFT_SERVE_SSH_LISTEN_ADDR=:23231
75+#SOFT_SERVE_SSH_KEY_PATH=ssh/soft_serve_host_ed25519
76+#SOFT_SERVE_INITIAL_ADMIN_KEYS='ssh-ed25519 AAAAC3NzaC1lZDI1...'
77+```
78+
79+> **Note** Soft Serve stores its server configuration and settings in
80+> `config.yaml` under its _data path_ directory specified using
81+> `SOFT_SERVE_DATA_PATH` environment variable.
82+
83+Now, let's write a new `/etc/systemd/system/soft-serve.service` Systemd service file:
84+
85+```conf
86+[Unit]
87+Description=Soft Serve git server 🍦
88+Documentation=https://github.com/charmbracelet/soft-serve
89+Requires=network-online.target
90+After=network-online.target
91+
92+[Service]
93+Type=simple
94+Restart=always
95+RestartSec=1
96+ExecStart=/usr/bin/soft serve
97+Environment=SOFT_SERVE_DATA_PATH=/var/local/lib/soft-serve
98+EnvironmentFile=-/etc/soft-serve.conf
99+WorkingDirectory=/var/local/lib/soft-serve
100+
101+[Install]
102+WantedBy=multi-user.target
103+```
104+
105+Great, we now have a Systemd service file for Soft Serve. The settings defined
106+here may vary depending on your specific setup. This assumes that you want to
107+run Soft Serve as `root`. For more information on Systemd service files, refer
108+to
109+[systemd.service](https://www.freedesktop.org/software/systemd/man/systemd.service.html)
110+
111+## Start Soft Serve on boot
112+
113+Now that we have our Soft Serve Systemd service file in-place, let's go ahead
114+and enable and start Soft Serve to run on-boot.
115+
116+```sh
117+# Reload systemd daemon
118+sudo systemctl daemon-reload
119+# Enable Soft Serve to start on-boot
120+sudo systemctl enable soft-serve.service
121+# Start Soft Serve now!!
122+sudo systemctl start soft-serve.service
123+```
124+
125+You can monitor the server logs using `journalctl -u soft-serve.service`. Use
126+`-f` to _tail_ and follow the logs as they get written.
127+
128+***
129+
130+Part of [Charm](https://charm.sh).
131+
132+<a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge-unrounded.jpg" width="400"></a>
133+
134+Charm热爱开源 • Charm loves open source