diff --git a/fhem/FHEM/98_systemd_watchdog.pm b/fhem/FHEM/98_systemd_watchdog.pm index 995baecc3..4a5974a09 100644 --- a/fhem/FHEM/98_systemd_watchdog.pm +++ b/fhem/FHEM/98_systemd_watchdog.pm @@ -2,7 +2,8 @@ # # Copyright notice # -# (c) 2018 Alexander Schulz +# (c) 2018 Alexander Schulz +# 2020 Christoph 'knurd' Morrison # # This script is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -219,76 +220,91 @@ sub watchdog_client_NotifySystemD($$) { 1; =pod -=item summary_DE Sendet periodisch eine keep-alive Nachricht an das Systemd. +=item summary_DE Sendet periodisch eine keep-alive-Nachricht an systemd. +=item summary Sends periodically keep-alive message to the systemd. + =begin html_DE -

Systemd Watchdog Client

+

systemd Watchdog Client

+ + Define +
define <name> systemd_watchdog
+

Legt einen neuen systemd-Watchdog mit dem Namen name an.

+ systemd service facility +

+ Um den Status überwachen zu können, muss FHEM durch systemd gestartet werden + und der systemd-Watchdog muss korrekt konfiguriert sein. Dazu kann das die folgende + systemd service facility genutzt werden: +

+ +
+  
+[Unit]
+Description=FHEM Home Automation
+Requires=network.target
+After=dhcpcd.service
+
+[Service]
+Type=forking
+NotifyAccess=all
+User=fhem
+Group=dialout
+
+# Run ExecStartPre with root-permissions
+ExecStartPre=-+/bin/mkdir -p /run/fhem
+ExecStartPre=+/bin/chown -R fhem:dialout /run/fhem
+
+# Run ExecStart with defined user and group
+WorkingDirectory=/opt/fhem
+ExecStart=/usr/bin/perl fhem.pl fhem.cfg
+#ExecStart=/usr/bin/perl fhem.pl configDB   # use for configDB
+TimeoutStartSec=240
+TimeoutStopSec=120
+
+# Stop service with root priviliges
+ExecStop=+/usr/bin/pkill -F /run/fhem/fhem.pid
+
+# Restart options: no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always.
+Restart=on-failure
+RestartSec=3
+WatchdogSec=180
+PIDFile=/run/fhem/fhem.pid
+
+[Install]
+WantedBy=multi-user.target
+  
+  
+ +

+ Das Script kann unter /etc/systemd/system/fhem.service abgelegt werden. + Mit sudo systemctl daemon-reload wird die systemd-Konfiguration + erneuert um die Änderungen zu aktivieren. Anschließend kann + FHEM mit sudo service fhem start gestartet werden. +

+ +

+ Wenn in der service unit Type=notify verwendet wird, muss in FHEM das globale Attribut + nofork=1 gesetzt sein: attr global nofork 1. +

+ +

+ Wird Type=forking muss in der systemd service facility der korrekte Pfad zu + der PID-Datei angegeben werden, die dann im globalen Device in FHEM mit + attr global pidfilename /run/fhem/fhem.pid konfiguriert werden kann. +

+ =end html_DE -=item summary Sends periodically keep-alive message to the systemd. =begin html @@ -302,56 +318,51 @@ sub watchdog_client_NotifySystemD($$) {

fhem must be started under control of systemd. Watchdog must be also configured properly.
You can use the following script:
- - [Unit]
- Description=FHEM Home Automation
- Requires=network.target
- #After=network.target
- After=dhcpcd.service
-
- [Service]
- Type=forking
- NotifyAccess=all
- User=fhem
- Group=dialout
- # Run ExecStartPre with root-permissions
- PermissionsStartOnly=true
- ExecStartPre=-/bin/mkdir -p /var/run/fhem
- ExecStartPre=/bin/chown -R fhem:dialout /var/run/fhem
- # Run ExecStart with defined user and group
- WorkingDirectory=/opt/fhem
- ExecStart=/usr/bin/perl fhem.pl fhem.cfg
- #ExecStart=/usr/bin/perl fhem.pl configDB
- TimeoutStartSec=240
- TimeoutStopSec=120
- #ExecStop=/usr/bin/pkill -U fhem perl
- ExecStop=/usr/bin/pkill -f -U fhem "fhem.pl fhem.cfg"
- # Restart options: no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always.
- Restart=on-failure
- RestartSec=3
- WatchdogSec=180
- PIDFile=/var/run/fhem/fhem.pid
-
- [Install]
- WantedBy=multi-user.target
-

- Create the script as "/etc/systemd/system/fhem.service". - Use "sudo systemctl daemon-reload" to reload systemd configuration. - Start fhem with: "sudo systemctl start fhem.service". -
- If you like to use Type=notify, you must set fhem global attribute nofork=1.
- attr global nofork 1
- If you use Type=forking, please set fhem global pidfilename.
- attr global pidfilename /var/run/fhem/fhem.pid
-

- +
+  
+[Unit]
+Description=FHEM Home Automation
+Requires=network.target
+After=dhcpcd.service
+
+[Service]
+Type=forking
+NotifyAccess=all
+User=fhem
+Group=dialout
+
+# Run ExecStartPre with root-permissions
+ExecStartPre=-+/bin/mkdir -p /run/fhem
+ExecStartPre=+/bin/chown -R fhem:dialout /run/fhem
+
+# Run ExecStart with defined user and group
+WorkingDirectory=/opt/fhem
+ExecStart=/usr/bin/perl fhem.pl fhem.cfg
+#ExecStart=/usr/bin/perl fhem.pl configDB   # use for configDB
+TimeoutStartSec=240
+TimeoutStopSec=120
+
+# Stop service with root priviliges
+ExecStop=+/usr/bin/pkill -F /run/fhem/fhem.pid
+
+# Restart options: no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always.
+Restart=on-failure
+RestartSec=3
+WatchdogSec=180
+PIDFile=/run/fhem/fhem.pid
+
+[Install]
+WantedBy=multi-user.target
+  
+  
+ +

Define

- - + =end html =cut