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: Raffi Khatchadourian <khatchad@xxxxxxxxxxxxxxxxxx>
Cc: offlineimap@xxxxxxxxxxxx
Subject: Re: OfflineIMAP and launchd
From: Vincent Beffara <vbeffara+ml@xxxxxxxxx>
Date: Thu, 22 Nov 2007 18:32:29 +0100

> <?xml version=3D"1.0" encoding=3D"UTF-8"?>
> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.=
com/DTDs/PropertyList-1.0.dtd">
> <plist version=3D"1.0">
> <dict>
>       <key>Debug</key>
>       <true/>
>       <key>KeepAlive</key>
>       <false/>
>       <key>Label</key>
>       <string>com.khatchadourian.raffi.offlineimap</string>
>       <key>ProgramArguments</key>
>       <array>
>               <string>/Users/raffi/local/offlineimap/offlineimap.py</string>
>               <string>-q</string>
>               <string>-u</string>
>               <string>Noninteractive.Quiet</string>
>       </array>
>       <key>RunAtLoad</key>
>       <false/>
>       <key>StartInterval</key>
>       <integer>120</integer>
> </dict>
> </plist>

That's pretty neat ! (And quite useful to have in the archives too.) Do=20
you know what happens if a given run of OfflineIMAP takes more than 2=20
minutes though ? That's unlikely to happen and I guess that launchd=20
would wait politely for the first one to exit before launching a second=20
one, but it would be nice to be sure of it ...

> #!/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=20
_before_ restarting the daemon (or whatever a launchd thing should be=20
called). I believe you are saved by setting RunAtLoad to false above,=20
but your script looks like it wants to kill offlineimap as soon as it is=20
started ...

BTW, a good replacement for your last line would be the following :

killall -HUP offlineimap

(plus maybe sleeping for a while and killing it more strongly). So I'd=20
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.

Cheers,

  /vincent

--=20
Vincent Beffara
UMPA - ENS-Lyon
46 all=E9e d'Italie
69364 Lyon Cedex 07
T=E9l : 04 72 72 85 25



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