An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

CFMX on OS X

December 2, 2004 · 12 Comments

I use a couple of scripts to make it easier to stop and start my CFMX instances on my Mac. I've also just created a small Mac application, using AppleScript, so I can start servers via a double-click application. First of all, a shell script to startup a CFMX instance:
#!/bin/sh
JRUN_HOME="/home/jrun"
LOG_HOME="${JRUN_HOME}/logs"
if test x$1 = x
then
server=default
else
server=$1
fi
cd ${JRUN_HOME}/bin
./jrun -start ${server} \
1>$LOG_HOME/${server}-out.log 2>$LOG_HOME/${server}-err.log &
Adjust the second line to match the location of your JRun install (probably /Applications/JRun4). Save this shell script somewhere as cfmxstart and make sure it is executable:
chmod +x cfmxstart
Now, from a Terminal window, you can start servers like this:
./cfmxstart
./cfmxstart blackstone
If you put the shell script on your PATH, you can omit the ./ part. Here's a similar shell script to shutdown an instance:
#!/bin/sh
JRUN_HOME="/home/jrun"
if test x$1 = x
then
server=default
else
server=$1
fi
cd ${JRUN_HOME}/bin
./jrun -stop ${server}
Same drill, change line 2, save it as cfmxstop, make it executable. Great, now what about doing this through a double-clickable Mac application? AppleScript to the rescue. Here's a simple AppleScript to run the shell script we just created:
display dialog "Start which server instance?" default answer "default"
do shell script "/Users/scorfield/bin/cfmxstart " & text returned of the result
You'll need to change the path to the shell script, I keep all my utility scripts in ~/bin. When run, this pops up a dialog asking which server to start, enter the name and click OK and - bingo! - your shell script runs. To create an application, select File > Save As... and then choose a file format of Application and check the Run Only checkbox and save it somewhere. Now you can drag the app to your dock for easy starting of CFMX. If you want to get adventurous, you could add Stop and Start buttons to the dialog and run the appropriate shell script. You could also change the icon to something more CF-y of course. Also, if you create AppleScripts that don't have dialogs, you can use them as Startup Items to cause your CFMX instances to startup whenever you boot up your Mac!
I couldn't resist... here's an AppleScript that lets you start and stop servers:
set scriptStem to "/Users/scorfield/bin/cfmx"
display dialog "Manage which server instance?" buttons {"Cancel", "Start", "Stop"} default answer "default"
set response to result
set operation to button returned of response
set serverName to text returned of response
if operation is "Start" then
   do shell script scriptStem & "start " & serverName
else if operation is "Stop" then
   do shell script scriptStem & "stop " & serverName
end if

Tags: coldfusion · osx

12 responses so far ↓

  • 1 Andrew Muller // Dec 2, 2004 at 4:24 PM

    Noice one Sean, noice, unusual, different...
  • 2 Dick // Dec 3, 2004 at 4:47 AM

    Neat Sean, all I need to do is getting CF working on my Mac!

    Anyone found out were Ken Ford has posted his install guide as Sean <a href="http://www.corfield.org/blog/index.cfm?do=blog.entry&entry=E0815F94-DFA6-5BC3-0C804776670DA850">blogged previously</a>?
  • 3 Erki Esken // Dec 5, 2004 at 3:48 AM

    Sean, why not use the graphical JRun Launcher instead? :)

    Just run /Applications/JRun4/bin/jrun without any command line options and the JRun Launcher GUI appears.
  • 4 Sean Corfield // Dec 5, 2004 at 2:23 PM

    Erki, that does not work due to AWT implementation issues on Mac OS X.
  • 5 Erki Esken // Dec 6, 2004 at 1:50 AM

    That is weird. Because after JRun 4 install (without updater) I could run it. Now after updater 4 is applied it doesn't work. I tried to make another config file with JVM set to 1.3.1 and run ./jrun -config jvm_1.3.1.config but no luck. Seems updater 4 changed something internally.
  • 6 Sean Corfield // Dec 6, 2004 at 9:17 AM

    Yup, JRun4 pre-Updater 4 used to spawn the JVM via the O/S and Apple decided that for "compatibility reasons" that operation should always spawn a 1.3.1 JVM (even if you had 1.4.x installed). So you ended up running CFMX on 1.3.1.

    JRun 4 Updater 4 fixes that problem by forcing a 1.4.2 JVM startup. The downside is that now you're exposed to the Apple AWT/Swing problem - which affects a lot of Java software with a graphical UI (including some Eclipse plugins).
  • 7 chris kief // Feb 13, 2005 at 6:20 PM

    The GUIs for wsconfig and the JRun launcher are still available, you just can't launch them through the /bin directory any more. Use the following:

    java -jar /Applications/JRun4/lib/jrun.jar
    java -jar /Applications/JRun4/lib/wsconfig.jar
  • 8 chris kief // Feb 13, 2005 at 6:57 PM

    So in the spirit of what Sean did, here's a shell script to invoke the Jrun Launcher GUI:

    #!/bin/sh
    JRUN_HOME="/Applications/JRun4"
    java -jar ${JRUN_HOME}/lib/jrun.jar
  • 9 chris kief // Feb 13, 2005 at 7:04 PM

    Try that again with some formatting. Save this file as startjrunlauncher:

    #!/bin/sh<br>
    JRUN_HOME="/Applications/JRun4"<br>
    java -jar ${JRUN_HOME}/lib/jrun.jar
  • 10 chris kief // Feb 13, 2005 at 7:05 PM

    Formatting didn't work - oh well. Next part is the AppleScript:

    set scriptStem to "/Users/ckief/desktop/mindflood/cfmx/"
    do shell script scriptStem & "startjrunlauncher"
  • 11 chris kief // Feb 13, 2005 at 7:06 PM

    One final note, be sure to made the shell script executable:

    chmod +x startjrunlauncher
  • 12 chris hough // Aug 16, 2009 at 10:25 PM

    ty so much for this thread, it really helped me add the starts and stops for cf as jrun into my existing applescripts for starting and stopping xampp services

Leave a Comment

Leave this field empty: