rmayr / dvcs-autosync

dvcs-autosync is a project to create an open source replacement for Dropbox/Wuala/Box.net/etc. based on distributed version control systems (DVCS). It offers nearly instantaneous mutual updates when a file is added or changes on one side but with the added benefit of (local, distributed) versioning and does not rely on a centralized service provider.
http://www.mayrhofer.eu.org/dvcs-autosync
Other
98 stars 14 forks source link

multiple autosync.py instances can run on the same directory #1

Open Dieterbe opened 13 years ago

Dieterbe commented 13 years ago

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?)

ngoonee commented 13 years ago

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).

rmayr commented 13 years ago

Writing pid file with default name derived from config file and preventing duplicate startup with same pid file implemented in commit d85965a

Dieterbe commented 13 years ago

1) 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:

So, /home/dieter/.config/dvcs-autosync/somedirectory.conf would give: /home/dieter/.cache/dvcs-autosync/somedirectory.pid

2) there should be a way to make autosync either:

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)

rmayr commented 12 years ago

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?