[systemd-devel] Monitor path to commit to git

Florian Lindner mailinglists at xgm.de
Thu Apr 7 18:11:19 UTC 2016


Hello,
I want to have a unit that monitors a path and commits automatically to
git whenever something changes. It usually works, like that:

# cat git-commit at .service
[Unit]
Description=Automatic commit for %f

[Service]
Type = oneshot
Nice = 10

# git returns 1 if there is nothing to commit
SuccessExitStatus=1

WorkingDirectory = %f
ExecStart = /usr/bin/git add --all .
ExecStart = /usr/bin/git commit -a -m "Automatic commit."


# cat git-commit at .path 
[Unit]
Description = Path monitor for %f

[Path]
PathChanged = %f

[Install]
WantedBy = multi-user.target

It basically works but has two issues:

1) The path unit does not seem to monitor the path recursively, therefore I don't get a commit when a file in a subdirectory changes

2)Sometimes the commit fails, like when an application pushes files to quickly into the directory:

Failed to start Automatic commit for /etc.
git-commit at etc.service: Start request repeated too quickly

or when files vanish before they are commited.

This is usally not a problem, and I just want to restart it (after a short delay) Setting Restart=on-failure on a Type=oneshort unit does not work git-commit at etc.service: 

Service has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.

Any idea how to address these two issues?

Thanks!
Florian



More information about the systemd-devel mailing list