Re: [launchd-dev] How to on demand launch for configurable port number?
Am 01.04.2008 um 13:34 schrieb Quinn <eskimo1@apple.com>:
At 22:15 +0100 29/3/08, Mike Fischer wrote:
Currently I'd immagine that I need to 'launchctl stop' the service, modify the associated launchd.plist to reflect the currently configured port and then 'launchctl start' the service.
You would probably have to "unload" and "load", rather than "stop" and "start". Stop/start just affects the running process, so launchd will not reconsult the relevant plist file.
Right, Thanks! (I'm still learning my way around the launchd world and its terminology.) So "unload" makes launchd completely forget about a service while "load" does the reverse?
Unless of course there is a better way that doesn't involve changing the launchd.plist?
I can't think of one.
OK.
Not sure if this is relevant but the daemon does not use Bonjour at the moment to advertise its service. That could be added though (and might be a good idea for other reasons).
If you used Bonjour, you could just bind to a ephemeral port ("SockServiceName" == "0") and find the service, which includes the port, using Bonjour. No need for fixed ports at all.
Sounds like a good idea. I'll have to look into this. Of course the clients would then need to rely on Bonjour as well which might be difficult to achieve as the Mac OS X port of the client software is only a small part of their customer base. I'm not sure I can convince them to use Bonjour on the other platforms. There may also be issues with Bonjour normally being Link-Local in situations where the end- users have more complex networks with multiple subnets. Using Dynamic DNS Update might be difficult to implement in the field. But all this is OT on this list I guess... Thanks for your time and insight! Mike -- Mike Fischer Softwareentwicklung, EDV-Beratung Schulung, Vertrieb Web: <http://homepage.mac.com/mike_fischer/index.html> Note: I read this list in digest mode! Send me a private copy for faster responses.
At 17:05 +0200 1/4/08, Mike Fischer wrote:
So "unload" makes launchd completely forget about a service while "load" does the reverse?
Right. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
At 10:20 +0100 2/4/08, Quinn wrote:
At 17:05 +0200 1/4/08, Mike Fischer wrote:
So "unload" makes launchd completely forget about a service while "load" does the reverse?
Right.
OK, that's was a little more succinct that I originally intended. Here's some more background: This one super-confusing part of launchd if you're coming to it from scratch. The lifecycle of a job is: load -> start -> stop -> [...] -> unload The load can be done implicitly (typically at the start of a session, for example, at startup time launchd loads all of the enabled jobs in /System/Library/LaunchDaemons) or explicitly (via "launchctl load"). Unloads, per se, only happen explicitly (via "launchctl unload"), but jobs are effectively unloaded if the session that they're loaded into dies (keep in mind that launchd's global session never dies). Similarly, the start can be done implicitly (via the RunAtLoad property, or by meeting one of your the launch-on-demand criteria, or by the KeepAlive property) or explicitly (via "launchctl start"). And a stop happens when the job quits or, explicitly, via "launchctl stop". S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
participants (2)
-
Mike Fischer
-
Quinn