On Fri, 2024-04-05 at 16:09 +0100, Peter Humphrey wrote:
> On Thursday, 4 April 2024 10:12:23 BST I wrote:
> 
> > Some of my machines run BOINC, which I want to stop while doing my sync &
> > update. For some reason, '/etc/init.d/boinc stop' often takes exactly 60s to
> > complete instead of its normal 6-10s.
> > 
> > I'd like my update script to detect this condition, but I can't see how.
> > I've tried grepping /bin/ps output, and I've tried checking for existence
> > of a BOINC pid file, but those both tell me that BOINC is "running" while
> > it's in the process of shutting down.
> > 
> > Is there somewhere in /proc where this shutting-down status is held?
> 
> Let me ask a different way: does start-stop-daemon keep the current, 
> transient 
> status of the daemon it's operating on anywhere other than in its own 
> variables, and thus accessible for inspection?
> 
> 

Not really. All start-stop-daemon is doing is sending SIGTERM/SIGKILL
signals to the boinc process:

  stop() {
    local stop_timeout="SIGTERM/60/SIGTERM/30/SIGKILL/30"

    env_check || return 1

    ebegin "Stopping ${RC_SVCNAME}"
    start-stop-daemon --stop --quiet --progress \
      --retry ${stop_timeout} \
      --pidfile "${BOINC_PIDFILE}"
    eend $?
  }

The "stop_timeout" thing says that a SIGTERM will be tried first, and
if that doesn't work, a second SIGTERM will be sent after 60s. If
*that* doesn't work, then finally a SIGKILL will be sent after an
additional 30s.

Personally, I would try to figure out why boinc doesn't want to stop
when you tell it to stop. But barring that, you could add pre- and
post-stop hooks that will let you know that the daemon is stopping.

For example, in /etc/conf.d/boinc, you could put

  stop_pre(){
    touch /run/stopping-boinc
  }
  stop_post(){
    rm -f /run/stopping-boinc
  }

or something like that. (I haven't tested, but the idea is sound.)
Then, if that file exists, boinc is stopping.



Reply via email to