add systemd templates
This commit is contained in:
@@ -90,6 +90,72 @@ later heartbeat.
|
|||||||
make [client|server]
|
make [client|server]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## systemd templates
|
||||||
|
|
||||||
|
Template units are available in:
|
||||||
|
|
||||||
|
```text
|
||||||
|
template/systemd/nexus-sync-server.service
|
||||||
|
template/systemd/nexus-sync-client.service
|
||||||
|
template/systemd/nexus-sync-client.timer
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace `ExecStart` with the absolute path to your built binary or script before installing.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
ExecStart=/opt/nexus-sync/nexus-sync-server
|
||||||
|
```
|
||||||
|
|
||||||
|
The client is a oneshot service triggered by a timer every minute.
|
||||||
|
|
||||||
|
### Install server service
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo install -Dm644 template/systemd/nexus-sync-server.service \
|
||||||
|
/etc/systemd/system/nexus-sync-server.service
|
||||||
|
sudo editor /etc/systemd/system/nexus-sync-server.service
|
||||||
|
sudo mkdir -p /var/lib/nexus-sync
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now nexus-sync-server.service
|
||||||
|
```
|
||||||
|
|
||||||
|
Optional server env file used by the template:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo install -Dm600 .env.example /etc/nexus-sync/server.env
|
||||||
|
sudo editor /etc/nexus-sync/server.env
|
||||||
|
sudo systemctl restart nexus-sync-server.service
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install client timer
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo install -Dm644 template/systemd/nexus-sync-client.service \
|
||||||
|
/etc/systemd/system/nexus-sync-client.service
|
||||||
|
sudo install -Dm644 template/systemd/nexus-sync-client.timer \
|
||||||
|
/etc/systemd/system/nexus-sync-client.timer
|
||||||
|
sudo editor /etc/systemd/system/nexus-sync-client.service
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now nexus-sync-client.timer
|
||||||
|
```
|
||||||
|
|
||||||
|
Install the client YAML config separately, for example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo install -Dm600 template/linux.yaml /root/.config/nexus/config.yaml
|
||||||
|
sudo editor /root/.config/nexus/config.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
Check status and logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl status nexus-sync-server.service
|
||||||
|
systemctl list-timers nexus-sync-client.timer
|
||||||
|
journalctl -u nexus-sync-server.service -f
|
||||||
|
journalctl -u nexus-sync-client.service -f
|
||||||
|
```
|
||||||
|
|
||||||
### To test
|
### To test
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=nexus-sync client heartbeat and command runner
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/absolute/path/to/nexus-sync-client
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Run nexus-sync client every minute
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=30s
|
||||||
|
OnUnitActiveSec=1min
|
||||||
|
AccuracySec=5s
|
||||||
|
Persistent=true
|
||||||
|
Unit=nexus-sync-client.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=nexus-sync server
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/absolute/path/to/nexus-sync-server
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
EnvironmentFile=-/etc/nexus-sync/server.env
|
||||||
|
WorkingDirectory=/var/lib/nexus-sync
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user