abiosoft / abiosoft/autoplank

Recommended Systemd Services

Aperta
#18 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
52
Fork
12
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I thought of contributing here as I like this autoplank instance. From how I had it before by using another autoplank iteration, using systemd is probably the better way to go about it.

If you like my recommendations, feel free to add it to your README @abiosoft

Here are my suggestions and take them for what is worth.

1. Create the service file as user, and the desired polling. Do not enable this service:

```
$ cat $HOME/.config/systemd/user/autoplank.service
[Unit]
Description=Autoplank Service

[Service]
ExecStart=/usr/local/bin/autoplank -p 200
Restart=always

[Install]
WantedBy=default.target
```

2. Create a systemd timer for this service and make the timer trigger the service:

```
$ cat $HOME/.config/systemd/user/autoplank.timer
[Unit]
Description=Timer for the AutoPlank user-mode service

[Timer]
OnActiveSec=5
Unit=autoplank.service

[Install]
WantedBy=timers.target
```

Additionally:
3. Create a new service to rescan and configure it to run once:

```
$ cat $HOME/.config/systemd/user/autoplank_scan.service
[Unit]
Description=Autoplank Monitor Scan Service
Wants=autoplank_scan.timer

[Service]
Type=oneshot
ExecStart=/usr/local/bin/autoplank -r

[Install]
WantedBy=default.target
```

4. Create a new systemd timer to trigger this rescanner. I set this to run every minute, be persistent, and to depend on the autoplank.service:

```
$ cat $HOME/.config/systemd/user/autoplank_scan.timer
[Unit]
Description=Timer for the AutoPlank Scan user-mode service
Requires=autoplank.service
After=autoplank.service

[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true
AccuracySec=1s

Unit=autoplank_scan.service

[Install]
WantedBy=timers.target
```

6. Enable ONLY the timers and not the services and start them. Consider the dependency when starting the timers:

```
$ systemctl enable autoplank.timer --user
$ systemctl enable autoplank_scan.timer --user
$ systemctl start autoplank.timer --user
$ systemctl start autoplank_scan.timer --user
```

Note: the services will show up as Loaded but inactive, and this is fine. Both services should show they are triggered by their timers:
* Service status:

![image](https://user-images.githubusercontent.com/54182057/216136626-cad05742-a3cc-4516-a3f1-8577fb34248a.png)

![image](https://user-images.githubusercontent.com/54182057/216136504-1a6593a0-8310-4cee-b026-82aefb12b364.png)

* Timer Status:

![image](https://user-images.githubusercontent.com/54182057/216138925-cad3862e-e5d6-47cc-a059-ec2f8d4b8c27.png)

![image](https://user-images.githubusercontent.com/54182057/216139140-61d78a56-ba53-49bb-8c4f-319c42db21d1.png)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.