Skip to content

Conversation

@danielfdickinson
Copy link
Contributor

📦 Package Details

Maintainer: @hnyman @s-hamann @drujd @tofurky @neheb @BKPepe @systemcrash @rpavlik

No maintainer, so spamming last 2.x years worth of folks who may be interested.

Description:
Updated configuration was not being applied after config change. This
was due to the means used to do the daemon reloads.

Closes #28298 "Drivers not restarted on config change"

Enable creating PID files for the server, driver, and monitor daemon
processes. This allows to use NUT's built-in facilities for signalling
the daemon's.

For server, when reloading:

  1. Check if upsd is running
    1. If not, start it.
    2. If it is send reload signal to upsd
  2. For each driver:
    1. Check if the driver is running
      1. If it is, send reload-or-exit signal to driver
      2. If driver is not running, start it
  3. Attempt to start server (upsd and drivers) if service was stopped.

For server, when stopping:

  1. Check if upsd is running
    1. If it is send stop signal to upsd
    2. Ensure it really is stopped
  2. For each driver:
    1. Check if the driver is running
      1. If it is, send stop signal to driver
      2. If driver is still running, stop it.
  3. If the server process is active (even with not upsd or drivers),
    stop it.

For monitor, send the reload signal on config change, with fallback to
stopping and starting the daemon.

In the process added linting (ignoring false positives) and fixed whitespace inconsistency.


🧪 Run Testing Details

  • OpenWrt Version: OpenWrt SNAPSHOT r32673-9d1f6ec49d
  • OpenWrt Target/Subtarget: bcm27xx/bcm2712
  • OpenWrt Device: aspberrypi,5-model-b

Only tested with dummy-ups so far. I have a spare UPS on order which should arrive this coming week.

Needs more testing and review.


✅ Formalities

  • I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

shellcheck is a useful linter if a bit pedantic and overzealous so
add overrides to silence false positives

Also, fix issues found by the linting.

* misspelling meant initscript could skip updating configuration in
  certain circumstances
* minor: assignment of the result of execution as the time of creating
  local. This has been separated.

likewise cspell is useful for getting spellings right and avoiding
typos, so override false positives for it as well

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
This is a noop, but since we are here.

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
@BKPepe BKPepe requested a review from Copilot January 19, 2026 04:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Updated configuration was not being applied after config change. This
was due to the means used to do the daemon reloads.

Closes openwrt#28298 "Drivers not restarted on config change"

Enable creating PID files for the server, driver, and monitor daemon
processes. This allows to use NUT's built-in facilities for signalling
the daemon's.

For server, when reloading:
1. Check if upsd is running
   1. If not, start it.
   2. If it is send reload signal to upsd
2. For each driver:
   1. Check if the driver is running
      1. If it is, send reload-or-exit signal to driver
      2. If driver is not running, start it
3. Attempt to start server (upsd and drivers) if service was stopped.

For server, when stopping:
1. Check if upsd is running
   1. If it is send stop signal to upsd
   2. Ensure it really is stopped
2. For each driver:
   1. Check if the driver is running
      1. If it is, send stop signal to driver
      2. If driver is still running, stop it.
3. If the server process is active (even with not upsd or drivers),
   stop it.

For monitor, send the reload signal on config change, with fallback to
stopping and starting the daemon.

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
@danielfdickinson danielfdickinson force-pushed the pr-nut-fix-reload-on-change branch from a298ac3 to 865f444 Compare January 19, 2026 07:25
start_service "$@"
local should_stop_upsd
local STATEPATH=/var/run/nut
local haveserver=0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does haveserver signify? That the file exists or it's running?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. It is that the upsd (server) configuration is present. Likewise havedriver should be haveupsconfig to differentiate between a driver and and a driver instance (which is for a specific ups). haveupsdconfig?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better. Make booleans as descriptive and concise as possible, here, so it's easy to follow what we're flagging. This nut thing is not simple, which possibly explains why we're in this situation to begin with :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to avoid words like "should" since we all know what happens in reality. shall or will or needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nut-server: Drivers not restarted on config change

2 participants