Not to worry got it sorted ... delete the lock file
Ok I've managed to get this running perfectly on my Gentoo Linux machine, but how should I get it to startup and shutdown cleanly? I can write a script or run a crontab to start it but how would I stop it automatically. I assume killall foldrajlite would not be appropriate
Better still if I could run to behave much like the windows service where it will only upload at 5000 structures and not upload at shutdown. Thanks
Not to worry got it sorted ... delete the lock file
However I find that if I delete the .lock file the client will stop after the next structure is completed ... but then uploads the data. I've put in a script to run the client and stop the client into my default run level.
Is there a way to prevent it from uploading when I stop the client, and only upload every 5000? Since proberbly by the time it starts to upload, the machine may well be shutdown. ThanksCode:#!/sbin/runscript start() { ebegin "Starting SLRI-Folding" cd ${FOLDING_DIR} ./foldit >&/dev/null& eend $? } stop() { ebegin "Stopping SLRI-Folding" cd ${FOLDING_DIR} rm foldrajlite.lock eend $? }
If it's linux, then it's supposed to wait until all threads have been stopped before it shuts down. That's normally why you see something lik e"Killing all threads", then it shuts down. Your conenction should still be there, and the machine should still be running when the client begins upload, because the client doesn't actually stop, then restart to upload, it's still running.
Thanks for the reply Darkness, upon shutdown the lock file does get deleted but unfortunately the client is getting killed I'm getting this in the error.log
Anyone know of any other way of starting this at boot and closing it cleanly at shutdown?Code:ERROR: [001.001] {foldtrajlite.c, line 1095} Caught sig 15
How about:
rm foldrajlite.lock
sleep (some number)
try sending it the letter 'Q'. Easiest way to do this would probably to write up a little proggie that starts up the client, and then just goes to sleep. When it gets the kill signal it can send the client the letter 'Q' through the redirected standard input and wait for it to finish up.
I thought about that, and I'll give it a go The problem that I can see is that sometimes it takes a while to to upload, could be having problems connecting to the server, and if it's not uploaded by the sleep counter stops the client will get "killed". Anyone knows how long it takes for the client to timeout when connecting to the server?
Thanks for the suggestions guys ... keep 'em coming
edit: Anyone know how you can stop the client from uploading when shutdown, without stopping the automatic upload every 5000? Heres a snip from the readme file on the windows service.
can this behaviour be done on the Linux client?The Windows version of the client can be set up to run as a normal Windows NT
service, so that it will start automatically whenever your computer starts up
and run in the background until you shut down. Structures will be uploaded
every 5000 still, and buffered for later upload at shutdown (so your shutdown
procedure will not be delayed)
Last edited by Mpemba Effect; 11-02-2002 at 04:51 PM.
This might be a better way to do it:
ps -C <process name> prints out a line based on whether or not <process name> is running. The exit status of ps is also successful if the process is running, and unsuccessful otherwise. So this will remove the lock file, check if foldtrajlite is running, and as long as it is, it will sleep one second and then check again.Code:#!/bin/sh rm -f foldtrajlite.lock while ps -C foldtrajlite >/dev/null 2>&1 ; do sleep 1 done
Oh yes mate! Thats solved it ... works very nicely, cheers bwkaz ... that was the missing line I needed For anyone else who's having the same problems heres the script i'm using:
Thanks for everyones helpCode:#!/sbin/runscript start() { ebegin "Starting SLRI-Folding" cd ${FOLDING_DIR} ./foldit >&/dev/null& eend $? } stop() { ebegin "Stopping SLRI-Folding" cd ${FOLDING_DIR} rm -f foldtrajlite.lock while ps -C foldtrajlite >/dev/null 2>&1 ; do sleep 1 done eend $? }
Good show, bwkaz!
That "ps -C" has come in handy a couple of times now.
Hey thanks. I had been using ps -ax | grep foldtrajlite for a while, but that would spit out spurious extra lines and stuff, so checking through the ps documentation for something better found -C. Works wonderfully.
What is ps -C? -C is an illegal option on Solaris 8.
The ps option -C in LINUX is select by command name. For example,
# ps -C sshd
PID TTY TIME CMD
1069 ? 00:00:18 sshd
27818 ? 00:00:07 sshd
From the Linux ps manpage:
-C is preceded by a single dash, and is therefore (as far as I can tell, anyway) a Unix98 option. Perhaps Solaris' ps isn't Unix98 or something?Code:COMMAND-LINE OPTIONS This version of ps accepts several kinds of options. Unix98 options may be grouped and must be preceeded by a dash. BSD options may be grouped and must not be used with a dash. GNU long options are preceeded by two dashes. Options of different types may be freely mixed.
<HaloJones> What is ps -C? -C is an illegal option on Solaris 8.
Yes, but solaris 8 has pgrep.
I didn't see one posted previously.... Here is the script that you have above, but re-written for Red Hat.
#!/bin/sh
#
# description: Foldit
# Source function library.
. /etc/rc.d/init.d/functions
# Change Directories
cd /usr/local/distribfold
RETVAL=0
# See how we were called.
case "$1" in
start)
./foldit > /dev/null 2>&1 &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
action "Starting Foldit: " /bin/true
else
action "Starting Foldit: " /bin/false
fi
;;
stop)
rm -f foldtrajlite.lock
RETVAL=$?
while ps -C foldtrajlite >/dev/null 2>&1 ; do
sleep 1
done
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/slamd
action "Stopping Foldit: " /bin/true
else
action "Stopping Foldit: " /bin/false
fi
;;
status)
if [ -e foldtrajlite.lock ]; then
echo "Foldit is Currently Running";
else
echo "Foldit is Currently Stopped";
fi
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
*)
echo "Usage: foldit {start|stop|restart|status}"
exit 1
esac
exit $RETVAL