dvcs-autosync icon indicating copy to clipboard operation
dvcs-autosync copied to clipboard

multiple autosync.py instances can run on the same directory

Open Dieterbe opened this issue 13 years ago • 4 comments

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

Dieterbe avatar Apr 03 '11 15:04 Dieterbe

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

ngoonee avatar Apr 16 '11 10:04 ngoonee

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

rmayr avatar May 12 '11 20:05 rmayr

  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:
  • 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

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

Dieterbe avatar May 13 '11 08:05 Dieterbe

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?

rmayr avatar Feb 17 '12 15:02 rmayr