Skip to main content

ColdFusion MX and JRun 4

Ok, is anybody else frustrated that between JRun 3 and JRun4, the ability to let users log into the JMC and see only their own JVMs was lost ?  Back in the good ole' days, you could assign a JCM to a JMC user and all was happy...

Anyway, i sought an answer to this for quite a while and never found a solution out there and Macromedia seems to be skirting the issue, so i said screw it, and came up with my own solution.  Note: This solution is for LINUX, not windows.  Sorry windows folks, you will have to try to adapt this solution.  Hope it works out.

Requirements:

  • Some experience with ColdFusion and JRun (4 preferably)
  • ColdFusion (any version, including CFMX running on JRun4)
  • JRun 4 - remember this is a tool for letting people restart JVMs on JRun
  • sudo installed on your Linux server (if you don't know what sudo is, leave right now -- im serious)

For the smart people using Linux, here is the general concept:


  1. Provide some place for your users to log in (this is your responsibility).  This is where you will provide the links for these users to restart their JVMs.

  2. Provide them with ColdFusion (cfml) pages that do a <cfexecute> to stop/start the specified JVMs

  3. Configure sudo on your server to allow the coldfusion user to run Jrun commands as root

  4. When a user chooses to stop/restart a server, sudo makes sure it is run with the proper permissions

NOTE:  This is not an exercise in security.  Use this technique as you want, but this comes with no warranty expressed or implied.  If you get burned, I don't want to know about it.  Use with care, as this is what worked on OUR servers, not YOURS.

Step 1: Configure sudo on your Linux Server

Ok, this step will allow the request to "restart" a JVM to run from somebody's web browser.  First, find out what user the ColdFusion server is running as.  If you have access to telnet or ssh for the server (you better, if you are doing this), then do a ps -ef and you should be able to easily figure out what user the ColdFusion server is running as:

nobody    3853  2484  0 15:17 ?        00:00:00 /opt/coldfusionmx/bin/cfusion -start default

^^^^^^^^

In this case, it is the user "nobody."

Ok, now edit the /etc/sudoers file and allow user "nobody" to execute the jrun admin program:

Cmnd_Alias      JRUN=/opt/jrun4/bin/jrun

nobody  ALL = NOPASSWD: JRUN

Note: This is not a lesson in how to use sudo or configure the sudoers file.  If you want that, go here.

Ok, now the user "nobody" can run the command /opt/jrun4/bin/jrun as root without being asked for a pssword. yum.

Obviously if your jrun4 is installed somewhere else, don't be silly, change the path to where yours is installed.

Step 2: Write some nifty CFML Code

Here are several code segments.  Use them as you see fit.  This isn't a complete application -- it will require you to figure out how to assemble them to meet your needs.  The variable #servername# is the name of the JVM you want to start/stop/etc.

Check to see if a JVM is running or not:

<cfset servername = "jvm_server">

<cfexecute 

    name="/usr/bin/sudo"

    arguments="-u root /opt/jrun4/bin/jrun -status #servername#"

    variable="status_info"

    timeout="20">

</cfexecute>

Stop the JVM:

<cfset servername = "jvm_server">

<cfexecute 

    name="/usr/bin/sudo"

    arguments="-u root /opt/jrun4/bin/jrun -stop #servername#"

    variable="status_info"

    timeout="20">

</cfexecute>

Start the JVM:

<cfset servername = "jvm_server">

<cfexecute 

    name="/usr/bin/sudo"

    arguments="-u root /opt/jrun4/bin/jrun -nohup -start #servername#">

</cfexecute>

Notice: When starting a JVM, we use the "-nohup" argument - this makes it not keep open a shell connection.  It also means we can't get back useful info about the JVM starting up.  The others have something useful returned in the "status_info" variable.

Well thats about it.  Have fun.  I have to run off and fix somebody else's universe now.

ciao

Popular posts from this blog

Making Macbook Air with 128GB SSD usable with Bootcamp

I recently got a new Macbook Air 11" (the 2012 version) and loaded it with goodies like 8GB ram and 2GHz Core i7.  What I DIDN'T upgrade was the internal SSD.  My config came with 128GB SSD and I refused to pay $300+ to upgrade it to 256GB.  Yeah I know, some call me cheap, but SSds cost $75-$150 for 240GB, so adding another 128GB for $300 seemed way too steep for me.  I figured "ok, I'm going to make 128G work!"

Here is the story of how that went...

Installing python 3.4.x on OSX El Capitan

I love "brew" package manager, but sometimes being too progressive breaks things.  I have several python apps that I maintain that get deployed to AWS using Elastic Beanstalk.  AWS eb can deploy with python 2.7 or 3.4.  Any recent 'brew install python3" will get 3.5.1. #annoying

Dell XPS M1330 + Snow Leopard Hackintosh

I have been working with a Dell XPS M1330 laptop for a few years now.  It doesn't quite match up to the newest notebooks in terms of performance, but it certainly still has some life in it.  I had previously installed OSX 10.5.x on it as an experiment, and had moderate success.  I decided to revisit this idea again to install Snow Leopard (OSX 10.6) on the Dell M1330, and keep some notes for those of you brave enough to Hackintosh your own machine...