dvcs-autosync
dvcs-autosync copied to clipboard
multiple autosync.py instances can run on the same directory
I can run autosync.py <path to config>
twice.
Both initialize, do the xmpp login, initial pull etc, but then you get (on both):
WARNING:root:AutosyncJabberbot:Received IOError while trying to handle incoming messages, trying to reconnect now
You can then kill one of them, and the remaining one will keep working normally. (I didn't dare to test what happens when you modify files in the git repository, but likely both instances will try to commit it at the same time)
autosync.py should somehow detect another instance is already running on the same directory/config and abort. optionally, a -k
flag to kill all instances and -k <config>
would kill any other instance running for the given config.
obviously, multiple instances should be able to run as long as they have a different config file. Actually, we should check for a different repository, but different config is likely easier to implement and should do the job. (why would a user have different configs pointing to the same repository?)
I just was testing and saw this behaviour, I was under the impression this is what the pidfile is meant to address (but it never gets created in my case).
Writing pid file with default name derived from config file and preventing duplicate startup with same pid file implemented in commit d85965a
- this is a violation of the xdg basedir spec. pid files do not belong in directories for configuration. instead of merely taking the filename of the config file and appending .pid, I propose:
- make user configure a directory where all pidfiles will go (maybe default to $XDG_CACHE_HOME/dvcs-autosync)
- store pidfiles in that directory, using the basename of the config (stripped of any extensions) as basename for the pidfile.
So, /home/dieter/.config/dvcs-autosync/somedirectory.conf would give: /home/dieter/.cache/dvcs-autosync/somedirectory.pid
- there should be a way to make autosync either:
- just kill another autosync instance which is using the same config
- kill another autosync instance which is using the same config, and replace it.
currently autosync-xdg-launcher.sh implements this in bash by inspecting the arguments of running autosync instances, but implementing it in the python code itself would be more robust, and more useful (for other use cases, like a user manually killing specific autosync instances)
To really fix this issue, it would need to be handled on all platforms, and I don't yet know how to do that without yet another platform dependent piece of code. Are you aware of a standard module that would allow to handle PID-style locking on all platforms?