New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #27578 (closed defect: worksforme)

Opened 2 years ago

Last modified 3 months ago

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

Reported by: greg@… 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

comment:1 Changed 2 years ago by ryandesign@…

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

comment:2 in reply to: ↑ description Changed 2 years ago by ryandesign@…

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 2 years ago by greg@…

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 2 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 2 years ago by sinuhet.merlin@…

  • Cc sinuhet.merlin@… added

Cc Me!

comment:6 follow-up: ↓ 7 Changed 2 years ago by snc@…

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

comment:7 in reply to: ↑ 6 Changed 19 months ago by jmr@…

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 11 months ago by ryandesign@…

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

comment:10 Changed 3 months ago by rmstonecipher@…

  • Status changed from new to closed
  • Resolution set to worksforme

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.