PDA

View Full Version : Feature request -- close down cleanly automatically



m.e
06-29-2003, 05:14 AM
It seems that at the moment, the client needs to be told to shut down, either by sending it a Q or by deleting the foldtrajlite.lock file.

It would be nice if the client would just close down nicely when it gets a SIGKILL without any human intervention.

Then it could be started at boot and shut down at powerdown.

Alternatively, you might provide some way of running from /etc/init.d (but not as root). Then the script could include code to shutdown nicely.

wirthi
06-29-2003, 06:09 AM
Hi,

you could also write a script that does "unlink foldtrajlite.lock", and sleeps for some seconds (until DF is no longer in the list of active processes).

m.e
06-29-2003, 06:24 AM
I tried to do something like that but I couldn't get it to work.

tpdooley
06-29-2003, 06:41 AM
At least in windows, we can install it as a service and it'll start and stop gracefully with the system.

bwkaz
06-29-2003, 01:49 PM
Originally posted by m.e
It would be nice if the client would just close down nicely when it gets a SIGKILL without any human intervention. Err, that's impossible. :)

On Unix, nothing can catch SIGKILL. Your process will be terminated, there's nothing you can do about it (you can't even run code before it shuts down).

You can catch SIGTERM, though, stop processing cleanly, and then exit. IIRC the client already does this, though (that was one of the things that got tested in the early betas; now I wonder whether it should've been tested a bit more later? *shrug*).


Then it could be started at boot and shut down at powerdown. You mean like this?


#!/bin/bash

. /etc/init.d/functions

case $1 in
start)
echo -n "Starting the Distributed Folding client..."
cd /path/to/distribfold
./foldit </dev/vc/11 >/dev/vc/11 &
evaluate_retval

;;

stop)
echo -n "Stopping the Distributed Folding client..."

rm -f /path/to/distribfold/foldtrajlite.lock

while ps -C foldtrajlite >/dev/null 2>&1 ; do
sleep 1
done

evaluate_retval

;;
esac I wrote this init script quite a while ago. It's worked for me ever since.

Put it in /etc/rc.d/init.d (or /etc/init.d if you use a slightly older version of LFS, like I do currently). Then create symlinks to it from /etc/rc.d/rc?.d (named either SXXXsomething or KXXXsomething, depending on whether you want to start it up or kill it in that runlevel -- and the XXX is 3 digits, though your system may only be set up to use 2, that determine the relative time that the script is run). Though I think you know this already, others may not. :)

You may have to change the evaluate_retval stuff, too. And the "echo -n". It all depends on how the rest of your distro's init scripts report success or failure.