Opened 12 years ago

Closed 10 years ago

Last modified 8 years ago

#36054 closed enhancement (fixed)

Feature request: reload action

Reported by: mailtoarlo@… Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts 2.4.0
Component: base Version:
Keywords: Cc: xeron (Ivan Larionov), ryandesign (Ryan Carsten Schmidt), eborisch (Eric A. Borisch), cooljeanius (Eric Gallager), raimue (Rainer Müller)
Port:

Description

When using ports that are started using launchd (e.g. apache2, mysql, php-fpm) the combination of port unload and port load is used to test configuration changes. Sadly typing this is long and cumbersome:

sudo port unload apache2 && sudo port load apache2

I suggest the port reload action that reduces the above to:

sudo port reload apache2

This is a common practice of "similar" commands like service.

Change History (14)

comment:1 Changed 12 years ago by mf2k (Frank Schima)

Priority: LowNormal
Type: requestenhancement

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

"sudo port load X" and "sudo port unload X" are only shortcuts for typing "sudo launchctl load -w /Library/LaunchDaemons/org.macports.X.plist" and "sudo launchctl unload -w /Library/LaunchDaemons/org.macports.X.plist" respectively. To my knowledge, launchctl does not provide a command for reloading or restarting something, therefore MacPorts does not provide such a shortcut.

comment:3 Changed 12 years ago by umassthrower@…

I'm not sure that a deficiency in launchctl is an appropriate reason to have a deficiency in port.

To start, having the "port reload X" command be a shortcut for "launchctl load -w /Library/LaunchDaemons/org.macports.X.plist && launchctl unload -w /Library/LaunchDaemons/org.macports.X.plist" seems like it would sufficiently simulate the user's expected behavior. I for one was slightly shocked today when sudo port reload dnsmasq failed as the reload/restart common case optimization is supported in most analogous systems as it is by far the most common use case of the load/reload/unload or start/restart/stop paradigm.

Last edited 12 years ago by umassthrower@… (previous) (diff)

comment:4 Changed 12 years ago by jmroot (Joshua Root)

For any launchd service that has KeepAlive specified, you get an automatic restart when you stop it. So you can simply run launchctl stop org.macports.apache2 or even apachectl stop.

comment:5 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: xeron.oskom@… ryandesign@… eborisch@… egall@… raimue@… added

Duplicate #42487 has a patch.

comment:6 Changed 10 years ago by xeron (Ivan Larionov)

Is there any reason for not applying patch from #42487?

comment:7 Changed 10 years ago by neverpanic (Clemens Lang)

Milestone: MacPorts Future
Resolution: fixed
Status: newclosed

Committed your patch in r123673 with the following changes:

  • Removed the delay. I don't think that's necessary, especially since port unload; port load doesn't have the delay and worked before.
  • Added the -w flag to unload and load just as it is in portload.tcl and portunload.tcl
  • Switched to Tcl 8.5's -ignorestderr flag instead of redirecting stderr to itself
  • Removed the change of src/port/port-help.tcl because that file is gone in trunk now. If you have some time, please consider writing a manpage (possibly for load, unload, and reload combined); see #44530 and wiki:NewHelpSystem for more information.

Thanks for the patch!

comment:8 Changed 10 years ago by xeron (Ivan Larionov)

I saw errors using "port unload; port load" with redis, it doesn't release tcp port in time. So sleep could be helpful here.

comment:9 Changed 10 years ago by neverpanic (Clemens Lang)

A reasonable point. I'm not sure how much wait time is appropriate, though. One second seemed too long to me because most daemons start in well under a second.

Also, this is a redis bug, IMO.

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

Since we use daemondo to handle all launch daemons, and since daemondo is documented to restart the process it's monitoring when it receives a SIGHUP, why don't we send that instead of unloading and loading again?

comment:11 in reply to:  10 Changed 10 years ago by neverpanic (Clemens Lang)

Replying to ryandesign@…:

Since we use daemondo to handle all launch daemons

We don't, see the mpstats and certsync ports, for example.

comment:12 in reply to:  9 Changed 10 years ago by xeron (Ivan Larionov)

Replying to cal@…:

A reasonable point. I'm not sure how much wait time is appropriate, though. One second seemed too long to me because most daemons start in well under a second.

Also, this is a redis bug, IMO.

There're lot of "sleep 1" in linux init scripts.

comment:13 Changed 10 years ago by neverpanic (Clemens Lang)

Oh well, better be safe than sorry then, I guess. r123716.

comment:14 Changed 8 years ago by jmroot (Joshua Root)

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