Running Railo from any directory

Today on the Railo mailing list someone asked if there was a way to start railo from any directory and use that directory as the web root. A fair enough question and it got me intrigued.

So after a bit of research I come up with the following, of course this works for OS X, change the relevant bits to suit your OS (hey, send me how to do it and I shall update the post)

First off, I downloaded Railo Express (3.3.4.003) and saved it to:

/Applications/railo_runner

Then I copied the ./start and renamed it to ./railo_runner

I added the path to ~/.bash_profile by adding:

export RAILO_RUNNER=/Applications/railo_runner/
export PATH=$PATH:$RAILO_RUNNER

so now, to change the railo_runner script. Mine looks like this:

#!/bin/bash
CURRPATH=$(pwd)
cd $(dirname $0)
java -DSTOP.PORT=8887 -DSTOP.KEY=railo -jar -Xms256M  -Xmx512M lib/start.jar -Drespath=$CURRPATH

The only thing I added was the current path and added it as a System property with the -D flag, as you can see by the -Drespath=$CURRPATH. All is good so far, now to tell Jetty to do something with it!

In the /Applications/railo_runner/contexts/railo.xml I changed the system property that is used for the resourceRoot:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"><Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/</Set>
<!--
  <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webroot/</Set>
-->

   <Set name="resourceBase"><SystemProperty name="respath" default="./webroot/"/></Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
</Configure>

Now I can do the following:
Earth:~ markdrew$ cd ~/Sites/
Earth:Sites markdrew$ mkdir demo_site1
Earth:Sites markdrew$ cd demo_site1
Earth:demo_site1 markdrew$ railo_runner

And voila! It creates the WEB-INF and you are good to go by http://localhost:8888!

del.icio.us Digg Facebook reddit Google Bookmarks
  1. Matt Levine

    #1 by Matt Levine - September 11, 2012 at 4:11 PM

    That's very cool!
  2. Mark Drew

    #2 by Mark Drew - September 11, 2012 at 4:56 PM

    It's actually good fun now! I don't have to do any virtual domains on my local machine, and I only really have one context running at a time.
  3. Joshua F. Rountree

    #3 by Joshua F. Rountree - September 12, 2012 at 10:00 AM

    Mark,
    FYI - here are the instructions written for Windows 7 that I constructed last night.

    http://www.joshuairl.com/blog/2012/09/12/running-railo-from-any-directory-in-windows-7/
  4. Mark Drew

    #4 by Mark Drew - September 12, 2012 at 10:27 AM

    Nice one Joshua! Will try it out, although I am getting strange pathing issues on Windows.

    Also see the update I added so that you don't have to hard code the railo installation path.
  5. tony petruzzi

    #5 by tony petruzzi - September 17, 2012 at 4:17 PM

    this is really cool. you ought to just make this part of the express download.
  6. Joshua Rountree

    #6 by Joshua Rountree - March 21, 2013 at 2:49 PM

    Is there an update to do this via latest version of railo express?
  7. Peter Bowater

    #7 by Peter Bowater - April 25, 2013 at 11:45 AM

    I've found it works, but you have to amend this line in railo_runner:

    java -DSTOP.PORT=8887 -DSTOP.KEY=railo -jar -Xms256M -Xmx512M start.jar -Drespath=$CURRPATH
(will not be published)
Leave this field empty: