Re: Example of launchd based application?
Re: Example of launchd based application?
- Subject: Re: Example of launchd based application?
- From: Andre-John Mas <email@hidden>
- Date: Sat, 12 Apr 2008 09:53:24 -0400
On 11-Apr-08, at 21:27 , Steve Sisak wrote:
(off list)
Hi Andre,
As Justin suggested, you might want to RTFM a bit -- there are some
very good launchd examples in the sample code section of
developer.apple.com.
I obviously did look hard enough, since I has tried searching on the
developer web site before posting the question. I'll have another
look. I'll certainly check the Darwin source, which I hadn't thought
of doing before.
Your understanding is a bit far afield in that your launchd plist
isn't a script and doesn't have a timeout or anything like that.
If you just want an application launched, you just tell launchd
"launch this application with these parameters" and (optionally)
relaunch it if it crashes.
This is the delicate part, since if does crash I need to limit how
soon, or how many times, it attempts to reconnect. Part of the
contract with the tunnel provider is that I don't reattempt to
reconnect too many times, too quickly in the case of issues. Doing so
would result in the tunnel end-point locking me out.
The program I am trying to move to launchd is not one which I wrote,
so I don't have much control over its behaviour.
If you provide a service, you can tell launchd to register the
service (TCP port, unix domain socket, whatever) on your behalf and
launch you if anyone accesses it.
When you're launched, you check in with launchd to get your file
descriptors then open whatever services you need, which may cause
launchd to launch them on demand.
This is possible, but I am not sure how well this interacts with a
service that is currently being launched using a StartUpItem, which
tun/tap is.
Anyway, hopefully this will give you a kick in the right direction.
Look at the docs and "man launchd.plist" to get started. (launchd is
very cool)
I'll take another look.
Currently I have, as a LaunchAgent:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd
">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.sixxs.Aiccu</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/aiccu</string>
<string>start</string>
<string>/etc/aiccu.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
but that will launch aiccu even if tun/tap is not ready.
I'll do some more digging.
Andre
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden