Opened 14 years ago

Closed 12 years ago

#27578 closed defect (worksforme)

mpd: killing daemon with "launchctl -w unload ..." has no visible effect (kills wrong process)

Reported by: gward (Greg Ward) Owned by: rmstonecipher@…
Priority: Normal Milestone:
Component: ports Version: 1.9.1
Keywords: Cc: sinuhet.merlin@…
Port: mpd

Description

I have installed mpd 0.15.15 and made just enough changes to /opt/local/etc/mpd.conf so that mpd runs usefully. I can start the daemon with

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mpd.plist

And now I can see two processes running:

$ ps -Aj | grep mpd | grep -v grep 
root     17635     1 17635 1edfd1c    0 Ss    ??    0:00.02 /opt/local/bin/daemondo --label=mpd --start-cmd /opt/local/etc/Launch
root     17637     1 17635 1edfd1c    0 S     ??    0:03.69 /opt/local/bin/mpd --no-daemon /opt/local/etc/mpd.conf

Note that one of these processes is mpd itself, and the other a daemondo instance that is presumably responsible for mpd. Seems reasonable.

Now let's say I decide to stop the daemon. My limited understanding of launchd leads me to believe that I am supposed to run

sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mpd.plist

However, this has no visible effect: mpd keeps running and the music keeps playing.

What seems to have happened is that the daemondo instance started by "launchctl load" was killed:

$ ps -Aj | grep mpd | grep -v grep
root     17637     1 17635 1edfd1c    0 S     ??    0:20.20 /opt/local/bin/mpd --no-daemon /opt/local/etc/mpd.conf

I expected both that daemondo instance and mpd to be killed.

Change History (9)

comment:1 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: rmstonecipher@… added
Owner: changed from macports-tickets@… to milosh@…
Port: mpd added

comment:2 in reply to:  description Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to greg@…:

I can start the daemon with

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mpd.plist

Or, equivalently (but easier to remember):

sudo port load mpd

sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mpd.plist

Or:

sudo port unload mpd

I expected both that daemondo instance and mpd to be killed.

Right, that's how it's supposed to work. I'm not sure why it's not working that way here.

comment:3 Changed 14 years ago by gward (Greg Ward)

Forgot to mention I'm on OS X 10.4.11. Perhaps launchd behaved a little differently back in ye olden days of Tiger. (This is on a G4, and I've tried running Leopard. Too slow. Tiger is just fine on this machine.)

Anyways, I "fixed" this for now by modifying the launchd properties file for mpd. Specifically, I made it a lot simpler, completely avoiding mpd.wrapper and daemondo:

        <key>ProgramArguments</key>
        <array>
                <string>/opt/local/bin/mpd</string>
                <string>--no-daemon</string>
                <string>/opt/local/etc/mpd.conf</string>
        </array>

Now launchd and mpd interact as I expected: "load -w" starts mpd and "unload -w" kills it.

Obviously, this is a short-term kludge: I assume it will be clobbered by the next upgrade of mpd.

comment:4 Changed 14 years ago by rmstonecipher@…

Greg,
I am glad you found a solution which works for you.

The launchd plist for dbus is much simpler than that for mpd.
In r49300, lines 121 through 167 explicitly write every line of the plist rather than utilizing MacPorts' startupitem routine.
One cannot run 'port load dbus' or 'port unload dbus' because load/unload looks for org.macports.[foo].plist and dbus provides org.freedesktop.dbus-system.plist.

Does your revised plist work with 'port load', or only with 'launchctl load'?
If you can either borrow from r49300 to write a simpler org.macports.mpd.plist or write a post-destroot routine to trim the fat from the startupitem generated files, and it can be run using port load/unload (i.e. no custom how-to-load message required), I take no issue with incorporating such a change into the mpd Portfile.

Ryan Stonecipher

comment:5 Changed 14 years ago by sinuhet.merlin@…

Cc: sinuhet.merlin@… added

Cc Me!

comment:6 Changed 14 years ago by nerdling (Jeremy Lavergne)

See #24042 for another solution (create a user for mpd).

comment:7 in reply to:  6 Changed 13 years ago by jmroot (Joshua Root)

Replying to snc@…:

See #24042 for another solution (create a user for mpd).

If #24042 is another solution for this problem, and it is fixed, that would mean that this is also fixed, no?

comment:8 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: rmstonecipher@… removed
Owner: changed from milosh@… to rmstonecipher@…

comment:10 Changed 12 years ago by rmstonecipher@…

Resolution: worksforme
Status: newclosed

I am going to trust that the lack of conversation in this ticket means 'port load' and 'add_users' fixed the glitch.

Note: See TracTickets for help on using tickets.