rework systemd stuff

move service to paths.target
remove startup dependency
change to try-reload-or-restart which has this logic:
  Reload service if it supports it.
  If not, stop and then start instead.
  Does nothing if the service is not running.
This commit is contained in:
Matthew Saunders Brown 2023-12-20 10:07:20 -08:00
parent c55d506d9c
commit c3ffd5c419
9 changed files with 7 additions and 11 deletions

View File

@ -1,10 +1,9 @@
[Unit]
Description="Reload Apache on changes to sites-enabled configs"
After=apache2.service
[Path]
PathChanged=/etc/apache2/sites-enabled/
Unit=vhost-reload-apache.service
[Install]
WantedBy=multi-user.target
WantedBy=paths.target

View File

@ -4,4 +4,4 @@ Description=Reload Apache
[Service]
Type=oneshot
ExecStartPre=sleep 2
ExecStart=systemctl reload apache2
ExecStart=systemctl try-reload-or-restart apache2

View File

@ -6,4 +6,4 @@ PathChanged=/etc/jailkit/jk_socketd.ini
Unit=vhost-reload-jailkit.service
[Install]
WantedBy=multi-user.target
WantedBy=paths.target

View File

@ -1,6 +1,5 @@
[Unit]
Description="Reload PHP-FPM on changes to pool config files"
After=php8.1-fpm.service
[Path]
PathChanged=/etc/php/8.1/fpm/pool.d/

View File

@ -4,4 +4,4 @@ Description=Reload PHP-FPM
[Service]
Type=oneshot
ExecStartPre=sleep 2
ExecStart=systemctl reload php8.1-fpm
ExecStart=systemctl try-reload-or-restart php8.1-fpm

View File

@ -1,6 +1,5 @@
[Unit]
Description="Reload Varnish on changes to site configs"
After=varnish.service
[Path]
PathChanged=/etc/varnish/sites.d/
@ -8,4 +7,4 @@ PathChanged=/etc/varnish/sites.vcl
Unit=vhost-reload-varnish.service
[Install]
WantedBy=multi-user.target
WantedBy=paths.target

View File

@ -4,4 +4,4 @@ Description=Reload Varnish
[Service]
Type=oneshot
ExecStartPre=sleep 1
ExecStart=systemctl reload varnish.service
ExecStart=systemctl try-reload-or-restart varnish.service

View File

@ -5,7 +5,6 @@
#
[Unit]
Description=Webalizer - generate stats from apache logs
After=logrotate.service
[Service]
Type=simple

View File

@ -90,7 +90,7 @@ do
cp systemd/$systemdConfig /usr/local/lib/systemd/system/$systemdConfig
chmod 644 /usr/local/lib/systemd/system/$systemdConfig
systemctl daemon-reload
systemctl --quiet is-active $systemdConfig && systemctl --quiet reload $systemdConfig
systemctl --quiet try-reload-or-restart $systemdConfig
echo "systemd/$systemdConfig updated"
echo
fi