From 25be87f949ed21d1b998f49492b96bf1f6c0b226 Mon Sep 17 00:00:00 2001 From: Tim Forbes Date: Thu, 28 Jun 2018 17:32:24 -0400 Subject: [PATCH 1/2] Systemd service file and accompanying integration notes. --- config/systemd.matrix-dimension.service | 24 +++++++++++++++ docs/notes/systemd.md | 40 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 config/systemd.matrix-dimension.service create mode 100644 docs/notes/systemd.md diff --git a/config/systemd.matrix-dimension.service b/config/systemd.matrix-dimension.service new file mode 100644 index 0000000..d092b7d --- /dev/null +++ b/config/systemd.matrix-dimension.service @@ -0,0 +1,24 @@ +[Unit] +Description=Integrations server for Matrix.org +After=network.target + +[Service] +ExecStart=/usr/local/bin/npm run start:app +WorkingDirectory=/home/matrix-dimension/git/matrix-dimension +Environment=NODE_ENV=production + +# Restart timing +Restart=always +RestartSec=60 + +# Output to syslog +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=matrix-dimension + +# User & group to run service as +User=matrix-dimension +Group=matrix-dimension + +[Install] +WantedBy=default.target diff --git a/docs/notes/systemd.md b/docs/notes/systemd.md new file mode 100644 index 0000000..6268b13 --- /dev/null +++ b/docs/notes/systemd.md @@ -0,0 +1,40 @@ +# Systemd Integration + +Run dimension as a systemd service and configure to start at boot. + +* Create service unit file +Save [systemd.matrix-dimension.service](https://github.com/turt2live/matrix-dimension/tree/master/config/systemd.matrix-dimension.service) to a systemd system path (e.g., `/etc/systemd/system/matrix-dimension.service`) + +* Enable and start the newly created service + +``` +$ systemctl enable matrix-dimension.service +Created symlink /etc/systemd/system/default.target.wants/matrix-dimension.service → /etc/systemd/system/matrix-dimension.service. +``` + +* Try starting it up and checking the status for errors +``` +$ systemctl start matrix-dimension.service +$ systemctl status matrix-dimension.service +``` + +* Reload systemd if any changes to the service file are necessary +``` +$ systemctl daemon-reload +$ systemctl restart matrix-dimension.service +``` + +* View logs +``` +$ tail -f /var/log/syslog | grep matrix-dimension +Jun 28 21:07:04 server1 matrix-dimension[913]: Jun-28-2018 21:07:04.582 +00:00 error [BridgeStore] connect ECONNREFUSED +Jun 28 21:07:04 server1 matrix-dimension[913]: Error: connect ECONNREFUSED +Jun 28 21:07:04 server1 matrix-dimension[913]: at Object._errnoException (util.js:1022:11) +Jun 28 21:07:04 server1 matrix-dimension[913]: at _exceptionWithHostPort (util.js:1044:20) +Jun 28 21:07:04 server1 matrix-dimension[913]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14) +``` + +## References +* [freedesktop.org](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Options) +* [axllent.org](https://www.axllent.org/docs/view/nodejs-service-with-systemd/) +* [digitalocean.com](https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units) From 53634853cb7564fa48e66255240dd440d2fb8e73 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 28 Jun 2018 16:01:14 -0600 Subject: [PATCH 2/2] Make the markdown processor happier --- docs/notes/systemd.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/notes/systemd.md b/docs/notes/systemd.md index 6268b13..12f03e7 100644 --- a/docs/notes/systemd.md +++ b/docs/notes/systemd.md @@ -2,8 +2,7 @@ Run dimension as a systemd service and configure to start at boot. -* Create service unit file -Save [systemd.matrix-dimension.service](https://github.com/turt2live/matrix-dimension/tree/master/config/systemd.matrix-dimension.service) to a systemd system path (e.g., `/etc/systemd/system/matrix-dimension.service`) +* Create service unit file. Save [systemd.matrix-dimension.service](https://github.com/turt2live/matrix-dimension/tree/master/config/systemd.matrix-dimension.service) to a systemd system path (e.g., `/etc/systemd/system/matrix-dimension.service`) * Enable and start the newly created service