[launchd-dev] How to on demand launch for configurable port number?

Mike Fischer mike_fischer at mac.com
Sat Mar 29 14:15:38 PDT 2008


Hi!

Let's say I have a daemon that listens on a TCP port. The exact port  
number can be configured, i.e. it is not fixed. It might even change  
when the user changes the configuration, albeit not very often.

Actually this daemon is a HTTP server that serves status information  
about a service. Thus it will not be used most of the time. Always  
running the server would be a waste of resources IMHO and I want  
avoid that by making it an on-demand service.

Is it possible to make launchd launch the daemon on demand when a  
connection request comes in? If so how would I specify this in the  
launchd.plist file, taking into account the varying TCP port number?


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. Unless of  
course there is a better way that doesn't involve changing the  
launchd.plist?

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).


I tried to find similar services, for example the Apache Web Server.  
But while it uses configurable port numbers it does not launch on  
demand unfortunatly. So I can't use it as an example of how to do this.


Thanks!
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.



More information about the launchd-dev mailing list