github.com/unigraph-dev/dgraph@v1.1.1-0.20200923154953-8b52b426f765/contrib/systemd/centos/README.md (about) 1 # systemd Integration for CentOS 2 3 The following document describes how to manage `dgraph` with `systemd`. 4 5 First, create a system account for `dgraph` service: 6 7 ``` 8 groupadd --system dgraph 9 useradd --system -d /var/run/dgraph -s /bin/false -g dgraph dgraph 10 mkdir -p /var/log/dgraph 11 mkdir -p /var/run/dgraph/{p,w,zw} 12 chown -R dgraph:dgraph /var/{run,log}/dgraph 13 ``` 14 15 Next, copy the `systemd` unit files, i.e. `dgraph.service`, `dgraph-zero.service`, 16 and `dgraph-ui.service`, in this directory to `/usr/lib/systemd/system/`. 17 18 > **NOTE** These unit files expect that Dgraph is installed as `/usr/local/bin/dgraph`. 19 20 ``` 21 cp dgraph.service /usr/lib/systemd/system/ 22 cp dgraph-zero.service /usr/lib/systemd/system/ 23 cp dgraph-ui.service /usr/lib/systemd/system/ 24 ``` 25 26 Next, enable and start the `dgraph` service. Systemd will also automatically start the 27 `dgraph-zero` service as a prerequisite. 28 29 ``` 30 systemctl enable dgraph 31 systemctl start dgraph 32 ``` 33 34 The `dgraph-ui` service is optional and, unlike `dgraph-zero`, will not be started 35 automatically. 36 37 ``` 38 systemctl enable dgraph-ui 39 systemctl start dgraph-ui 40 ``` 41 42 If necessary, create an `iptables` rule to allow traffic to `dgraph-ui` service: 43 44 ``` 45 iptables -I INPUT 4 -p tcp -m state --state NEW --dport 8000 -j ACCEPT 46 iptables -I INPUT 4 -p tcp -m state --state NEW --dport 8080 -j ACCEPT 47 ``` 48 49 Check the status of the services: 50 51 ``` 52 systemctl status dgraph 53 systemctl status dgraph-zero 54 systemctl status dgraph-ui 55 ``` 56 57 The logs are available via `journald`: 58 59 ``` 60 journalctl -u dgraph-zero.service --since today 61 journalctl -u dgraph-zero.service -r 62 journalctl -u dgraph.service -r 63 journalctl -u dgraph-ui.service -r 64 ``` 65 66 > **NOTE** When `dgraph` exits with an error, `systemctl status` may not show the entire error 67 output. In that case it may be necessary to use `journald`.