Re: [gentoo-user] Program shutting down - where is its status held?

2024-04-07 Thread Peter Humphrey
On Friday, 5 April 2024 16:21:15 BST Michael Orlitzky wrote:

> 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.

Nice, neat solution. Works a charm, too.

Thanks again, Michael.

-- 
Regards,
Peter.






Re: [gentoo-user] Program shutting down - where is its status held?

2024-04-05 Thread Peter Humphrey
On Friday, 5 April 2024 16:21:15 BST Michael Orlitzky wrote:

> Personally, I would try to figure out why boinc doesn't want to stop
> when you tell it to stop.

Actually, it does; all its daughter process do stop straight away. It's just 
that it doesn't report completion when it should.

> 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.

Outstanding! I'll try that. Thank you Michael.

As to the primary problem, I think the BOINC team aren't entirely in tune with 
the Linux way of doing things - though I could be wrong, of course. They're 
university boffins, after all...  :)

-- 
Regards,
Peter.






Re: [gentoo-user] Program shutting down - where is its status held?

2024-04-05 Thread Michael Orlitzky
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.





Re: [gentoo-user] Program shutting down - where is its status held?

2024-04-05 Thread Peter Humphrey
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?

I have tried reading the code, but I'm not familiar with the Linux way of 
organising programs, and it's far too long since I did anything even remotely 
similar.

-- 
Regards,
Peter.






[gentoo-user] Program shutting down - where is its status held?

2024-04-04 Thread Peter Humphrey
Hello list,

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?

-- 
Regards,
Peter.