Tech/OSS/systemd/Restart on config change

From lathama
< Tech‎ | OSS‎ | systemd
Jump to navigation Jump to search

An example of using systemd to restart a service on config change, needs more work but getting there

configchange.service
[Unit]
Description=configchangewatcher
After=network.target

[Service]
Type=simple
WorkingDirectory=/etc/path
ExecStart=/bin/service

[Install]
WantedBy=multi-user.target


configchange-watcher.service
[Unit]
Description=configchange restarter
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart configchange.service

[Install]
WantedBy=multi-user.target
configchange-watcher.path
[Path]
Unit=configchange-watcher.service
PathChanged=/etc/configdir

[Install]
WantedBy=multi-user.target