Re: Launch Daemon Best Practices?
Re: Launch Daemon Best Practices?
- Subject: Re: Launch Daemon Best Practices?
- From: Chris Suter <email@hidden>
- Date: Wed, 12 Mar 2008 13:14:07 +1100
On 12/03/2008, at 12:39 PM, Karl Moskowski wrote:
Why would that location be wrong?
If your preferences aren't user specific, I don't think they should be
there. You also shouldn't be running your daemon as root unless you
absolutely have to.
After Hamish's original response, I thought the way to go would be
to create a proxy object that behaves like NSUserDefaults (KVC- and
KVO-compliant, so it can be wired up in IB) but really just
interacts with a corresponding object in the daemon from DO. That
way, the daemon's settings are fresh, and the UI always reflects the
correct state.
As I said, I don't think it's a good idea to control your daemon
directly from the UI. If your daemon isn't running, you can't use the
UI to change the preferences. Likewise, if it crashes whilst you're
trying to change something or if it's slow in responding you have to
handle that. I personally think you'd be better off writing the
preferences and then telling your daemon to refresh.
If you need to get state information out of your daemon, then
distributed objects is one way of doing it, but I would put that kind
of communication on a separate thread in case your daemon becomes
unresponsive for whatever reason. If you just need to find out whether
your daemon is running, you could just write a file containing the pid
to /var/run like other daemons do. You can then trigger a refresh by
sending SIGHUP. Doing things this way allows you to completely control
your daemon from the command line which can be desirable for testing
and server scenarios.
BTW, which Xcode project template would be most appropriate for this
type of launch daemon? CoreFoundation Tool or CoreServices Tool?
I don't know. I doubt there's much difference between the two. It's
easy enough to add other frameworks as you need them.
Anyway, this is straying off Cocoa a bit so replies should probably be
off-list.
Kind regards,
Chris
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden