2 files changed, 39 insertions, 0 deletions
diff --git a/contrib/systemd/log_config.yaml b/contrib/systemd/log_config.yaml
new file mode 100644
index 0000000000..e16fb5456a
--- /dev/null
+++ b/contrib/systemd/log_config.yaml
@@ -0,0 +1,23 @@
+version: 1
+
+# In systemd's journal, loglevel is implicitly stored, so let's omit it
+# from the message text.
+formatters:
+ journal_fmt:
+ format: '%(name)s: [%(request)s] %(message)s'
+
+filters:
+ context:
+ (): synapse.util.logcontext.LoggingContextFilter
+ request: ""
+
+handlers:
+ journal:
+ class: systemd.journal.JournalHandler
+ formatter: journal_fmt
+ filters: [context]
+ SYSLOG_IDENTIFIER: synapse
+
+root:
+ level: INFO
+ handlers: [journal]
diff --git a/contrib/systemd/synapse.service b/contrib/systemd/synapse.service
new file mode 100644
index 0000000000..2e8cd21c9e
--- /dev/null
+++ b/contrib/systemd/synapse.service
@@ -0,0 +1,16 @@
+# This assumes that Synapse has been installed as a system package
+# (e.g. https://aur.archlinux.org/packages/matrix-synapse/ for ArchLinux)
+# rather than in a user home directory or similar under virtualenv.
+
+[Unit]
+Description=Synapse Matrix homeserver
+
+[Service]
+Type=simple
+User=synapse
+Group=synapse
+WorkingDirectory=/var/lib/synapse
+ExecStart=/usr/bin/python2.7 -m synapse.app.homeserver --config-path=/etc/synapse/homeserver.yaml --log-config=/etc/synapse/log_config.yaml
+
+[Install]
+WantedBy=multi-user.target
|