-
-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upsdrvctl can not run in the foreground #1874
Comments
Oh, forget this. |
Thinking about it, the bigger context is (I think) that "normally" - per older NUT behavior - drivers were always backgrounding except when debugged (then they were foregrounded unconditionally). Relatively recently explicit options were added to ensure fore-/back-grounding of drivers and other daemons. Also #1287 was posted to pass debugging level request from |
Just to be sure - are you building current/recent Git HEAD of NUT? Not an older release tag like 2.7.4 or 2.8.0? (That PR was merged this January). Also, what command are you starting the driver with? Including the device name on command line, or not? |
Thank you for answer. I just want to make this run in docker with my Arm device and one container per driver. I indeed compile recent Git HEAD of NUT for -F option and run |
Still can't wrap my head around why people want containers for NUT. It has many purposes, but usually the main one is to shut down the system, not sure if containers may command the host environment that much. (Well, with a bind-mounted host procfs you can echo into sysrq handler or some such). Likewise, on the system managing the UPSes it should run a copy of the driver late in shutdown routine (with FSes unmounted etc.) after all clients have disconnected, to tell the UPS to cut power, where possible. I suppose no containers are runnable at that point... But please, feel free to enlighten me, I do have a feeling people know something I don't :D |
At least, after some trial and error I can indeed confirm some sort of bug here, thanks. It seems the fix for foreground mode did not account in |
On a side note, these retries with a |
The upsd and driver run on an arm device (like Respberry Pi), which I don't care force shutdown. Other devices run nut client and connect to upsd(on arm device via network). For convenience, I make docker image for nut to run on such device(special linux release without package manager like apt). Don't known it is a correct way and I just use a huawei ups2000 for my home lab. |
For this bug. I think when need run in the foreground, invoke |
Got a holistic fix in progress... |
Regarding runs "on ARM" - ideally you do care to shut it down, at least to have filesystems safe. On a Raspberry with MMC/SD card you might also want to look into reducing writes (to minimize flash wear-out), e.g. running the host OS mounted read-only mostly and containers with virtual file systems (tmpfs...) if you truly do not care about their data. Still, if you want your home lab to come back up automagically in most cases, you should look into telling the UPS to cut power when things begin a shutdown routine. This should ensure that whenever wall power appears (and maybe when batteries become sufficiently charged), all your useful load will power on - even if you are not home to push power buttons. With reasonable UPSes this should also cover the case that power returned too early - while you were shutting down (by Murphy's law, this does happen and too often): it turns off, discovers wall power, turns on, acting as a big reset for everything it feeds. |
Would you like to check in practice if that PR's source branch works better for your use-case, before I merge it? |
PR #1424 was tested on huawei ups2000, fore/background mode both work very well! And thank you very much for the elegant solution #1874 (comment), I will try later~~ |
I meant to test PR #1875 - git branch at https://github.com/jimklimov/nut/tree/issue-1874 Rough start could be like:
more suggestions in https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests |
Seems a little bug here
|
Well, sending "signal 0" is the OS-independent way of checking if the other process exists. Fiddling with e.g. However this can be compromised by lack of permission to send the signal (unprivileged user owning This probably could be refactored (return more states than zero/nonzero, parse the PID file once and error out if it does not exist; use the same PID number in later retries and avoid extra disk I/O and string-to-number parsing), but so far it was not the focus of the exercise. |
Other than the messages, did it work functionally? :) Also, in this test case, you seem to have checked |
Yes, driver can run in foreground with -F and then stopped by Ctrl+C. And |
Well, thanks to you too :) Feel free to hang around, find and maybe even fix some more issues, scratch some itches :) |
PR merged, closing issue. |
Hello.
I just want to run single driver in the foreground. Just add -F option did not work.
The upsdrvctl is compiled in ubuntu 22.04 x64 with follow cmds:
So... debug and find some problem with waitpid()
nut/drivers/upsdrvctl.c
Line 304 in 72d3253
Every time startup, waitpid() return -1 and now errno is EINTR.
Follow code just ignore EINTR and fix this bug(?) for me.
Did this a bug or something else?
The text was updated successfully, but these errors were encountered: