Re: rc script: manual stop vs system shutdown

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Mon, 12 Aug 2019 10:46:29 +0300
On 01/08/2019 22:51, Ian Lepore wrote:
> On Thu, 2019-08-01 at 21:14 +0300, Andriy Gapon wrote:
>> On 01/08/2019 19:12, Warner Losh wrote:
>>>
>>>
>>> On Thu, Aug 1, 2019, 10:53 AM Rodney W. Grimes
>>> <freebsd-rwg_at_gndrsh.dnsmgr.net <mailto:freebsd-rwg_at_gndrsh.dnsmgr.net>>
>>> wrote:
>>>
>>>     >
>>>     > Is it possible in an rc script to distinguish between a manual stop
>>>     > (e.g., service foo stop) and a stop during a system shutdown (via
>>>     > rc.shutdown) ?
>>>     > Are there any marker variables for that?
>>>     > Or something in the global system state?
>>>
>>>     Not that I can think of, but I like this idea,
>>>     I am sure that use cases exist.
>>>
>>>
>>> What is the use case that needs to disambiguate the two cases...
>>
>> I have one use case in mind and it's a truly special case.
>> I want rc.d/watchdogd to gracefully stop watchdogd and to disable the
>> watchdog timer when the stop action is requested manually.  And I want
>> it to stop watchdogd and set the watchdog timer to a special shutdown
>> timeout during the shutdown.  If the special timeout is configured, of
>> course.
>>
> 
> The shutdown timeout is already supported:  you just set '-x <timeout>'
> in watchdogd_flags in rc.conf; no changes to the rc.d script needed.
> 
> I think probably you don't even need the first part of what you want. 
> The -x arg covers you in the reboot case; most people probably won't
> use it.  But if you are using it, and you want to truly kill the dog,
> you would just do "watchdog -t 0" after "service watchdogd stop".  If
> you really felt the need to cover that with a single service command,
> then how about using "service watchdogd cancel" where the cancel verb
> does the -t 0 after killing the daemon?

I guess that there is more than one way to achieve what I want or
something similar to that.
Rather than "expend words" on a theoretical discussion, I decided to do
this: https://reviews.freebsd.org/D21221
However, I am still open to the discussion and suggestions.
One thing that I would prefer, though, is to make the watchdogd service
as smart as possible -- but not smarter :-) -- that is, I would prefer
to do without adding any new command verbs to it.


-- 
Andriy Gapon
Received on Mon Aug 12 2019 - 05:46:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:21 UTC