Systemd service file and accompanying integration notes.

This commit is contained in:
Tim Forbes 2018-06-28 17:32:24 -04:00
parent 8f125f3ba6
commit 25be87f949
2 changed files with 64 additions and 0 deletions

View File

@ -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

40
docs/notes/systemd.md Normal file
View File

@ -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 <uri snip>
Jun 28 21:07:04 server1 matrix-dimension[913]: Error: connect ECONNREFUSED <uri snip>
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)