Merge pull request #201 from leprasmurf/systemd_integration

Systemd service file and accompanying integration notes.
This commit is contained in:
Travis Ralston 2018-06-28 16:05:36 -06:00 committed by GitHub
commit f773b7a3ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 63 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

39
docs/notes/systemd.md Normal file
View file

@ -0,0 +1,39 @@
# 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)