I was reading another guide that showed how to do this in FreeBSD. I thought, Great idea! But there seemed to be a lot of differences, and it was outdated to boot. So here we are.
For this guide, I'm going to use daemontools in OpenBSD. I use it (daemontools) for djbdns and qmail (and publicfile in the past), and it works great. It's too bad there's all that drama between DJB and Theo, which means us OpenBSD users don't even get a port. Anyway, it just makes more sense to use daemontools than using the finstall script, which is the longest shell script I've ever seen, and I hope never to see another like it. It also required that the account that would run Folding at Home would have their shell set to bash. Ick.
The first step is to install daemontools (not that the order matters all that much). Fetch the latest version from it's official site, presently 0.76, and follow djb's installation instructions there. I follow them to the letter with one exception: I edit conf-cc
and add -O2 -march=athlon-tbird
, but you should use your own architecture, of course. Unless you run a Thunderbird. In which case, internet-high-five! Compilers usually optimize better than you can, without the need to write cryptic source code. Also, be sure to get the man pages.
Now daemontools will be started at boot because the install script adds an invocation of /command/svscanboot
to the end of /etc/rc.local
. I removed this and added the following to the top of /etc/rc.local
(that is, before anything other services are started):
if [ -x /command/svscanboot ]; then echo -n ' daemontools' /command/svscanboot & fi
I wish I could start it sooner, since I also use djbdns for DNS lookups and it might be important for some services to start properly (like NTP). I'm not about to go editing /etc/rc
to achieve this, and I certainly won't promote such things.
For future reboots, you'll need to edit the appropriate line of /etc/sysctl.conf
. This will help you out until then:
sysctl kern.emul.linux=1
Install as a port from emulators/fedora/base
...
cd /usr/ports/emulators/fedora/base make install
... or install the package ...
pkg_add fedora_base
You'll want a group and a user called folding
:
groupadd -v folding useradd -mv -c'Folding at Home' -d/var/folding -gfolding -s/sbin/nologin folding
Give folding
a place to live:
cd /var/folding mkdir root log /var/log/folding
You should find the latest version, but I'll make an assumption about the version below. I'm also assuming you have the wget package, but you can replace it with whatever you like:
cd /var/folding # The following is completely wrong: wget http://www.stanford.edu/group/pandegroup/folding/release/FAH6.02-Linux.tgz cd root tar xzf ../FAH6.02-Linux.tgz ./fah6 -configonly
You can remove mpiexec
. I don't think you even can run it, anyway.
daemontools will need a pair of scripts to get going: one for the daemon process and another for the log process.
cd /var/folding vi run #!/bin/sh cd /var/folding/root exec /usr/local/bin/setuidgid folding \ /usr/bin/nice -n 20 \ ./fah6 2>&1 vi log/run #!/bin/sh exec /usr/local/bin/setuidgid folding \ /usr/local/bin/multilog t /var/log/folding chmod 744 run log/run chown -R folding:folding . /var/log/folding
If you don't like those crazy long timestamps that multilog puts in the log files (e.g. @400000004897013125fa05e4), you can remove the t
'script' (the term that multilog uses) from log/run
.
ln -s /var/folding /service
That's it. To stop, start, or restart the service (respectively):
svc -d /service/folding{,/log} svc -u /service/folding{,/log} svc -t /service/folding{,/log}
To check up on the service, use svstat
(if the uptime doesn't go above 1, the script or the programs it is invoking are crashing):
svstat /service/folding{,/log} /service/folding: up (pid 1384) 40043 seconds /service/folding/log: up (pid 736) 40043 seconds
You can find the log at /var/log/folding/current
, though fah6
still writes a log at /var/folding/root/FAHlog.txt
.
C'est tout! That wasn't so bad, was it? If you're like me, you should be realizing right about now that daemontools is a valuable tool. Also, if you have any corrections, email me. My contact info is up two levels from here.