**** Running Tahoe LAFS in the foreground ****

To install and run TAHOE LAFS the first time just follow instructions (doc/running.html).  Follow the additional docs if you set it up for another environment such like I2P.

After it is running properly you probably want to run it in the foreground, such that you can control it better.  I for my part always want to run daemons under a PTY just in case, because I then can see what happened if something happened, for example I can see a timestamp when the child came home.  For this I use my own tool named [ptybuffer|http://www.scylla-charybdis.com/tool.php/ptybuffer] and run it via autostart.sh from cron.

The trick to run it in foreground is, that you must run TAHOE in the ~/.tahoe directory (this is where all TAHOE data lives), then everything is fine:
[[
#!/bin/bash

export PATH="$HOME/tahoe/tahoe-lafs-i2p/bin:${PATH}"
export PYTHONPATH="$HOME/tahoe/tahoe-lafs-i2p/support/lib/python2.5/site-packages:${PYTHONPATH}"

echo `date` start
cd .tahoe
# Nice, if in wrong directory this fails silently.  Bad design
exec "$HOME/tahoe/tahoe-lafs-i2p/bin/tahoe" run
]]

This assumes that you have installed tahoe in $HOME/tahoe.  If you have different paths, change them accordingly.

If you wonder how to move the TAHOE filestore, then just use a softlink for ~/.tahoe/storage like this:

[[
~/.tahoe$ ls -al
total 40
drwxr-xr-x  5 tino tino 4096 Feb 18 00:19 .
drwxr-xr-x 46 tino tino 4096 Feb 28 08:15 ..
-rw-------  1 tino tino    5 Feb 28 12:55 client.port
drwxr-xr-x  3 tino tino 4096 Feb 18 00:19 logs
-rw-r--r--  1 tino tino   33 Feb 28 12:55 my_nodeid
-rw-------  1 tino tino   23 Feb 28 12:55 node.url
drwx------  3 tino tino 4096 May 12  2010 private
lrwxrwxrwx  1 tino tino   12 May 12  2010 storage -> /write/tahoe
-rw-r--r--  1 tino tino  291 May 12  2010 tahoe-client.tac
-rw-r--r--  1 tino tino 1089 May 12  2010 tahoe.cfg
drwxr-xr-x  2 tino tino 4096 May 12  2010 tmp
]]


*** Comments ***

It could be so easy, but it isn't.  For unknown reason the designers of TAHOE LAFS have decided to run TAHOE in background by default, which is bad.  The problem of daemonizing things is, that if the daemon fails, thing break badly.

{{
If you create a daemon, make sure nothing can break.  Always make sure that if something breaks, that the daemon is restarted.  Else you fail.
}}

It's not easy to run TAHOE in the foreground because it silently fails.  It just does not tell what's wrong.  This is another epic fail.  Applications must be elaborative enough to tell people that something failed and why.  With shell scripts this is not that important, as you can run it "bash -x".  But with Python it is important to do an extensive logging until you are sure everything works, as there is no easy way to debug things.

More important if you use a framework like Twistd, which is a little difficult to diagnose as well in such a case.

-Tino, 2011-02-28