acme: refactor #19669
This is racy; two processes could run the check at the same time and both end up continuing. You'll have to use an atomic operation to actually create the lock; for shell scripts that's usually mkdir. See this example from sqm-scripts for how to do it right:
https://github.com/tohojo/sqm-scripts/blob/master/src/run-openwrt.sh#L80-L103
General refactoring is OK by me; however, please split each change out into a separate commit, with a commit message explaining the problem it's fixing, and how it's being fixed.
Also, the locking is racy, see below...
Fixed. I decided to use flock. Seems it's designed specifically for this use case.
Updated as requested.
I'm pretty sure this doesn't work the way you think it does; how did you test it?
Sorry, I tested it in a small test script, but when tried to expand it in the real script, I got it wrong. It should be fixed.
I also fixed one more bug during testing, and took the liberty to add support for a new option. Let me know what you think.
Yeah, that's better!
Approved these changes.
tohojo
hgl
acme getSigned-off-by: Glen Huang <i@glenhuang.com>
Maintainer: @tohojo
Description:
Using hotplug to reload a service can inadvertently restarting it if it was stopped, as pointed out by @ptpt52.
This PR make services use procd instead, which is how it should be properly done IMO. It also moves the actual notifying logic out of hooks, since they really shouldn't be concerned about how to actually do that.
@tohojo, if you think the design is good I will change other related services too.