Opened 8 years ago

Closed 5 months ago

Last modified 4 months ago

#23677 closed enhancement (fixed)

Deactivating a port should automatically unload daemons

Reported by: tomldavis@… Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts 2.5.0
Component: base Version: 1.8.2
Keywords: startupitem launchctl Cc: ryandesign (Ryan Schmidt), cooljeanius (Eric Gallager), mkae (Marko Käning)
Port:

Description

I'm developing on a port that starts a daemon using startupitem.executable. During installation, I get the standard message "A startup item has been generated ...". After I start the daemon with launchctl, everything works as expected.

However, if I uninstall the port without first manually unloading the daemon with launchctl, launchd repeatedly tries to restart the daemon (which of course no longer exists) every 10 seconds, ad infinitum.

This behavior (not automatically unloading daemons on uninstall) seems contrary to the MacPorts philosophy of a clean install/uninstall. This seems like a huge trap for the non-developer that doesn't have any idea of what launchd does and just wants to uninstall a port.

Change History (14)

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

Cc: ryandesign@… added

And when you upgrade a port that you've previously loaded, perhaps MacPorts should unload the old version's daemon and load the new one.

comment:2 Changed 7 years ago by ryandesign (Ryan Schmidt)

Resolving this would also close #14774 where this was previously brought up.

comment:3 Changed 7 years ago by rmstonecipher@…

Cc: rmstonecipher@… added

Cc Me!

comment:4 Changed 7 years ago by rmstonecipher@…

On the other end of things, ports with startupitems usually work best when their startupitems are loaded.
If the port with a startupitem is several steps ahead of the user's requested port install, the "load the startupitem" note may be missed.
Could the user be cut out of this equation by auto-loading startupitems during the activate phase?
This would work for ports with startupitems which work as-is, but others may experience one or more of the following problems:

  • some ports use both user- and system-level startupitems (e.g. dbus)
  • some ports have configuration files that must be edited before running the daemon/startupitem

What other issues could auto-loading startupitems cause?

Ryan Stonecipher

comment:5 Changed 4 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:6 Changed 3 years ago by mkae (Marko Käning)

Cc: mk@… added

Cc Me!

comment:7 in reply to:  4 Changed 20 months ago by ryandesign (Ryan Schmidt)

Replying to rmstonecipher@…:

If the port with a startupitem is several steps ahead of the user's requested port install, the "load the startupitem" note may be missed.

MacPorts 2.4 will consolidate all notes printed by the notes command at the end of all installs. I don't know if it will do the same for other notes not printed by the notes command, such as the notes about launchd plists.

Could the user be cut out of this equation by auto-loading startupitems during the activate phase?

For most ports, automatic loading is probably not appropriate. For example, before a user can load their MySQL server, they may need to edit its configuration file.

Ports can opt-in to automatic loading of plists using startupitem.autostart yes. For example the certsync port does this, since there is no configuration file, no options for the user to select.

comment:8 Changed 5 months ago by jmroot (Joshua Root)

Summary: Uninstall of a port should automatically unload daemonsDeactivating a port should automatically unload daemons

comment:9 Changed 5 months ago by jmroot (Joshua Root)

Resolution: fixed
Status: newclosed

In 738e5f5a450a800687f9946969550ac73fdd5d98/macports-base:

Unload startupitems at deactivate time

Also load the startupitem of newly upgraded ports if it was loaded
for the old version.

Fixes: #23677

comment:10 Changed 5 months ago by jmroot (Joshua Root)

Milestone: MacPorts Future

comment:11 Changed 4 months ago by neverpanic (Clemens Lang)

Milestone: MacPorts FutureMacPorts 2.5.0

comment:12 Changed 4 months ago by neverpanic (Clemens Lang)

Milestone: MacPorts 2.5.0MacPorts Future

comment:13 Changed 4 months ago by ryandesign (Ryan Schmidt)

Cc: rmstonecipher@… removed

comment:14 Changed 4 months ago by jmroot (Joshua Root)

Milestone: MacPorts FutureMacPorts 2.5.0
Note: See TracTickets for help on using tickets.