happs-tutorial-0.8: templates/runtutoriallocally.st
<h3>Run This Tutorial Locally</h3>
<p> Before going further, you may want to inform yourself about the <a href=/tutorial/prerequisites>basic prerequisites</a>, both knowledge and equipment, you need to make the best use of this tutorial. </p>
<p>This tutorial is cabalized. You can install it, and chase down all the Happstack dependencies it needs, simply by doing
<p>cabal install happs-tutorial</p>
<p>If you've never used cabal install or need more detailed info see the <a href="http://hackage.haskell.org/trac/hackage/wiki/CabalInstall">cabal install</a> homepage.</p>
<p>If you want to use the latest version of this tutorial, install <a href="http://www.darcs.net">Darcs</a> and check out the repo with darcs get http://patch-tag.com/publicrepos/happstack-tutorial.</p>
<p>The reason I cabalized happs-tutorial was for the dependency chasing you get with cabal install,
not for actually running it.</p>
<p>Cabal installs an executable somewhere that you can run, but the tutorial pages won't display because
the executable needs template files to display pages correctly. To actually run the tutorial locally, copy the
happs-tutorial.tar.gz distribution file that cabal downloaded -- probably somewhere under ~/.cabal if you're on linux.
The following command </p>
<p><i>find ~/.cabal | grep -i happs-tutorial</i> </p>
<p>should show you a tar file. Otherwise, you can just download the tar file from
<a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tutorial">hackage</a>.
Once you have the tar file, untar this somewhere, cd into that, build and run here as described below. Finally, you could darcs get happs-tutorial and run there.</p>
<p>To run the app, either do ./hackInGhci.sh and then execute runInGhci inside Main.hs or run the happs-tutorial executable created by cabal install, with the caveat that you do need to be in the base directory of happs-tutorial.
You shouldn't need to run inside of ghci, but the option is available.
<p>Suggested runtime options: <i>happs-tutorial 5001 True True</i></p>
<p>Shutdown with ctrl-c.</p>
<p>
You should now be able to browse this tutorial offline by running the executable, and opening http://localhost:5001 in your browser.</p>
<p>Every so often, when starting via runInGhci, you may get an error message like:</p>
<p>*Main> runInGhci
happs tutorial running in ghci.
exit :q ghci completely and reenter ghci, before restarting.
*** Exception: _local/happs-tutorial_state/events-0000000006: openFile: resource busy (file is locked)
</p>
<p>Don't worry about it. Every time I get this error I simply run runInGhci again, and the second time it always works.</p>
<p>This issue does not occur when you run the tutorial from a compiled executable, which is of course how you should be running for a production application.</p>
<p>You may also want to <a href="start-happstack-on-boot">start Happstack on boot</a>.</p>
<p>Next up is a first example of using <a href="/tutorial/your-first-happstack">Happstack</a>.</p>