Viewing By Entry / Main
December 2, 2004
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

Comments

Noice one Sean, noice, unusual, different...


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>?


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.


Erki, that does not work due to AWT implementation issues on Mac OS X.


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.


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).


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


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


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


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

set scriptStem to "/Users/ckief/desktop/mindflood/cfmx/" do shell script scriptStem & "startjrunlauncher"


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

chmod +x startjrunlauncher


Post Your Comments
Name:
Email Address:
Comments
*** Please note that all comments require moderation so it may be some time before your comment posts to this blog! ***
Remember My Information:
 



Hosting provided by