I have a problem with my systemd setup. I have a service that starts my MEAN-Stack environment on the server.
[Unit]
Description=Frontend Server
After=network.target backend.service
[Service]
Type=simple
User=meanrunner
ExecStart=/somepath/server.sh
Restart=always
WorkingDirectory=/somepath/
[Install]
WantedBy=multi-user.target
I now added an automatic deployment pipeline and to make it work I added a .path and a .service file for every service in order to restart them when a deployment happened.
[Path]
Unit=frontend-watcher.service
PathChanged=/somepath
[Install]
WantedBy=multi-user.target
[Unit]
Description=frontend restarter
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart frontend.service
[Install]
WantedBy=multi-user.target
So far it actually kind of works with one issue. The setup is triggering too fast and too often because the watcher is triggered for every uploaded file. There is an error message due to this but it still works and the files are updated (the website runs the new code).
Now I was wondering if there is a way to change the behavior. Ideally to only trigger after the upload is done. My only (server newbie) idea is to upload one last file after every deployment and only watch this one file. That way it would only trigger at the end once. But I thought there might be a better way.