1 (edited by samcrawford 2011-08-23 12:09:38)

Topic: Making a dependent service restart after change in LuCI

Morning,

I'm trying to make a service (privoxy) restart when a user changes the Dnsmasq settings in LuCI.

I understand from previous posts and from reading the code that /etc/config/ucitrack is used to determine dependent services and what should be restarted. So I made the following changes:

config dhcp
        option init dnsmasq
        list affects privoxy

config privoxy
        option init privoxy

I also made sure that /etc/init.d/privoxy existed, was executable, and the service was enabled (I see entries for privoxy in /etc/rc.d/). I also have /etc/config/privoxy with some minimal configuration inside.

This, as I understand it, should be all that is required to have dnsmasq and privoxy restart when a user changes DHCP settings in LuCI.

However, I see that dnsmasq restarts when pressing 'Save & Apply', but privoxy does not. I've added logger statements into the privoxy init script and see that it is not called. I also added logger statements into /sbin/luci-reload and see that it is only called with one argument: "dhcp". This suggests to me that it is not finding privoxy as a dependent service for some reason.

Any suggestions? I see there have been posts on this before, and I will write up a Wiki article on this to answer it definitively once this is solved.

Thanks,

Sam

Re: Making a dependent service restart after change in LuCI

Okay, to answer my own thread:

If you have a CBI page in LuCI with a Map that affects a service (say "dhcp" in my case), then LuCI will *not* restart 'affected' services listed in /etc/config/ucitrack. It will only restart the service listed in the first argument to Map(...)

This is managed by an Ajax callback to /cgi-bin/luci/;stok=XXXXXX/servicectl/restart/<service>, which in turn invokes action_restart() in /usr/lib/lua/luci/controller/admin/servicectl.lua. Neither action_restart() nor the function that generate the HTML printing the Ajax callback make a lookup to the affected services list.

This seems odd to me, as a lot of the required functionality for looking up affected services is in _affected() in /usr/lib/lua/luci/model/uci.lua.

Quick solution: If you want to restart an affected service then you can create a dummy Map relating to the appropriate service in your CBI, and then return that along with the primary one. This will then force LuCI to generate the Ajax callback with a link pointing at /cgi-bin/luci/;stok=XXXXXX/servicectl/restart/dhcp,privoxy.

For example:

m = Map("dhcp","DHCP")
-- Lots of sections etc relating to "m" here
m2 = Map("privoxy", "")
return m, m2

Note to LuCI developers if they're reading: I'd be happy to work up a patch to LuCI to support reading the 'affects' config from /etc/config/ucitrack. Of course, if I'm missing something please do say.

Thanks,

Sam

Re: Making a dependent service restart after change in LuCI

Thx for reporting back!

I placed a link to this in OpenWrt wiki:  http://wiki.openwrt.org/doc/techref/luci

Re: Making a dependent service restart after change in LuCI

No problem. I'd be interested in hearing from the community & LuCI developers if this is considered a bug, or if I'm simply doing something wrong. I post it to the LuCI list this evening if I don't hear anything back.

Thanks,

Sam

Re: Making a dependent service restart after change in LuCI

Yeah, I noticed.

That is because all the developers (that all booze gourmets) are meeting in secret, to conjure the recipe for a new tasty beverage. If you read news about a bunch of drunken hackers anywhere in this world, it's probably gonna be the secret location.

Consider using other communications channels:  http://wiki.openwrt.org/meta/communication
Try IRC first.

Re: Making a dependent service restart after change in LuCI

Orca wrote:

That is because all the developers (that all booze gourmets) are meeting in secret, to conjure the recipe for a new tasty beverage. If you read news about a bunch of drunken hackers anywhere in this world, it's probably gonna be the secret location.

Sounds like my kind of development!

Re: Making a dependent service restart after change in LuCI

Yes, after this incident:  Galapagos-Iguano eats OpenWrt contributor the project just isn't the same any more.

Damn Galapagos-Iguanos!

Re: Making a dependent service restart after change in LuCI

Quick bump for any LuCI developers lurking around...

Re: Making a dependent service restart after change in LuCI

You have good detailed info there, so you might create a ticket in the LuCI bugtracker, so that the LuCI developers (mainly 'jow' for the back-end stuff) will notice it.

http://luci.subsignal.org/trac/timeline