Managing launchd
Ryan Schmidt
ryandesign at macports.org
Fri Jul 3 06:13:29 PDT 2009
On Jul 2, 2009, at 11:06, Panagiotis Atmatzidis wrote:
> I have a mac mini G4 that acts as a server on my home LAN offering
> services (dns, http, AFP, etc).
>
> I've installed dnsmasq but I don't know how to make launchd start
> dnsmasq on boot. I understand that this has something to do with
> launchd but I could not find any documentation on how to do it.
You may want to install (the older Tiger version of) Lingon, which is
a GUI for managing launchd. You may find this more comfortable than
typing launchd commands in the Terminal.
> My second issue is that when I've installed lighttpd, I did a quick
> configuration on the lighttpd.conf in order to make it work. I copy
> and paste at the terminal the command line in order to start the
> demon via launchd at boot something like this:
>
> sudo launchctl load -w /Library/LaunchDaemons/
> org.macports.lighttpd.plist
>
> Now the problem is that while, I can clearly see that lighttpd
> doesn't bind any port(!) is running and apparently every time I
> kill the process it starts by itself, so at this point I don't have
> control over this. How can manage this situation? I want to
> configure it first and the put it at startup. Here's what I'm
> talking about:
>
> devo:/opt/local/etc atma$ ps auwx|grep -i lighttpd
> root 23921 0.0 0.1 27956 780 ?? Ss 6:57PM
> 0:00.01 /opt/local/bin/daemondo --label=lighttpd --start-cmd /opt/
> local/etc/LaunchDaemons/org.macports.lighttpd/lighttpd.wrap
> atma 23937 0.0 0.0 27812 4 p4 R+ 7:05PM
> 0:00.00 grep -i lighttpd
As you see above, lighttpd is not in fact running. daemondo (the
MacPorts launchd helper program) is running, but lighttpd itself is
not. What probably happened is that launchd started daemondo, which
started lighttpd, which noticed a problem with its configuration
file, printed an error message (which you could not see) and quit. I
use lighttpd too so I have experienced this as well. Before getting
lighttpd running with launchd, you may just want to run the lighttpd
executable yourself in the Terminal. If there is an error in the
config file, you will be able to see the error message that way. Once
you have your config file correct (and indeed the sample config file
the MacPorts lighttpd port installs is awful and needs to be
massively rewritten; I believe there is a ticket open on this), then
you can stop your manually-started lighttpd in the Terminal and use
launchd to keep it up.
Note that the MacPorts lighttpd launchd plist will not in fact keep
lighttpd running if it crashes. This is also a bug in how the port is
set up, and there should be a ticket for that as well.
The maintainer of the lighttpd port hasn't been doing much with it,
so these issues are unlikely to get fixed by him. I have wanted to
fix them, but have not been sufficiently motivated. If you would like
to supply patches to fix any of these or any other issues you
encounter with lighttpd in MacPorts that would be appreciated.
More information about the macports-users
mailing list