Re: Example of launchd based application?
Re: Example of launchd based application?
- Subject: Re: Example of launchd based application?
- From: Steve Sisak <email@hidden>
- Date: Sat, 12 Apr 2008 11:59:32 -0400
At 9:53 AM -0400 4/12/08, Andre-John Mas wrote:
On 11-Apr-08, at 21:27 , Steve Sisak wrote:
(off list)
Oops, I see you cc'd the list -- no worries, was just trying to keep
noise down.
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.
SampleD was the example I was thinking of.
<http://developer.apple.com/samplecode/SampleD/index.html>
Google "site:developer.apple.com launchd daemon"
and check out the first 5 hits.
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.
We'd need to know more about the behavior of your application but
this might be a start:
<http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/LaunchOnDemandDaemons.html#//apple_ref/doc/uid/TP40001762-DontLinkElementID_12>
xinetd compatibility mode might be of use to you as well.
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.
Normally, you just wait until your service is ready. Can you describe
your service's requirements in more detail?
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.
My understanding is that aiccu should just block until its
dependencies are ready.
HTH,
-Steve
_______________________________________________
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