[systemd-devel] Monitor path to commit to git
killermoehre
killermoehre at gmx.net
Fri Apr 8 10:47:43 UTC 2016
Am 07.04.2016 um 20:11 schrieb Florian Lindner:
> 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
Hi Florian,
for this I normally use https://github.com/axkibe/lsyncd, which can do
this recursivly. In my use case I sign packages this way after building.
Regards
More information about the systemd-devel
mailing list