Complete.Org: Mailing Lists: Archives: offlineimap: November 2007:
Re: OfflineIMAP and launchd
Home

Re: OfflineIMAP and launchd

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: offlineimap@xxxxxxxxxxxx
Subject: Re: OfflineIMAP and launchd
From: Raffi Khatchadourian <khatchad@xxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Nov 2007 12:42:29 -0500

Vincent,

On Thu 22.Nov'07 at 18:32:29 +0100, Vincent Beffara wrote:
>That's pretty neat ! (And quite useful to have in the archives too.) 

Thanks!

>Do you know what happens if a given run of OfflineIMAP takes more than
>2 minutes though ?

Well, since I'm using the new -q option (quick) I don't have this
problem, but to answer your question, yes, offlineimap will just exit
and say that there is already an instance executing with the same
metadata directory.

>That's unlikely to happen and I guess that launchd would wait politely
>for the first one to exit before launching a second one, but it would
>be nice to be sure of it ...

Nevertheless, from my understanding launchd is pretty smart.

>> #!/bin/bash
>> /bin/launchctl stop com.khatchadourian.raffi.offlineimap
>> /bin/rm -f /Users/raffi/.offlineimap/lock /Users/raffi/.offlineimap/pid
>> /bin/launchctl start com.khatchadourian.raffi.offlineimap
>> ps -ef | grep "offlineimap" | grep -v grep | awk '{ print $2 }' | xargs kill 
>> -HUP
>
>That got me a little bit worried, as I would tend to kill the process
>_before_ restarting the daemon (or whatever a launchd thing should be
>called). 

You're correct, its a little strange but for ever reason it does work.
It seems that the previous instance just gets stuck and once you unstick
it (i.e., kill it), launchd kicks in and starts another one. It may very
well work another way around but I haven't tried it.

>I believe you are saved by setting RunAtLoad to false above, 

Yes, I played around with this parameter but I couldn't see much of a
difference when I set it to true or false.

>but your script looks like it wants to kill offlineimap as soon as it
>is started ...

It does seem that way but see my above comment.

>BTW, a good replacement for your last line would be the following :
>
>killall -HUP offlineimap

True, but that didn't work for me since the parent process is Python, so
I would need to say killall -9 Python but if I have another python
process running that wouldn't be desirable.

>(plus maybe sleeping for a while and killing it more strongly). So I'd 
>rather say
>
>#!/bin/bash
>launchctl stop com.khatchadourian.raffi.offlineimap
>sleep 2 # Just in case
>killall -HUP offlineimap
>sleep 2 # Just in case
>killall offlineimap
>rm -f /Users/raffi/.offlineimap/lock /Users/raffi/.offlineimap/pid
>sleep 2 # Just in case
>launchctl start com.khatchadourian.raffi.offlineimap
>
>I might be missing something obvious there, though.

That may work except for the Python issue I mentioned above.

Raffi



[Prev in Thread] Current Thread [Next in Thread]