Steven Erat's Blog Steven Erat Photography
 
 
Viewing By Entry
 
 

TalkingTree  System boot scripts for CFMX on JRun on Linux

 

While CFMX 6/7 Server Configuration on Unix and Linux ships with boot scripts that upon system reboot will kick off ColdFusion automatically, this feature is not a part of CFMX 6.1 for JRun or CFMX 7 Multiserver configurations.

I've written and tested these boot scripts that will start ColdFusion 6.1 or 7 on Red Hat Enterprise Linux 3 and 4 at system boot when using either the JRun/Multiserver configuration or an EAR/WAR configuration for JRun. Once installed to the system, root user can use the service command to start the ColdFusion instance from anywhere on the system without having to cd to /etc/init.d/ or to $JRUN_HOME/bin.

The example boot scripts can be used as a starting point. To use it:

  • make a copy of one of the boot scripts from the download archive, rename it to something meaningful like jruncfmx7ear to reflect the purpose of the script,
  • move it to /etc/init.d/ directory, (this should already have the executable bit set for root, but if not then chmod the file to 700)
  • edit the script using vi or another text editor,
  • note the area intended for CUSTOMIZATIONS and edit the parameters as described by the comments, such as $JRUN_INSTANCE=cfusion to indicate that the instance name you would like the script to start is cfusion,
  • then use chkconfig to officially register the script to start or stop at certain run levels, for example
    chkconfig --add jruncfmx7ear which will set the script to run in runlevels 2, 3, 4, and 5 or to specify particular run levels use chkconfig --levels 3 to have the script run when entering only runlevel 3, which is the default run level for a server OS not having X Windows.
  • To check how the script is configured, use chkconfig --list jruncfmx7ear in this case.
  • If you have multiple CF/JRun instances, you can have one of these scripts per instance so that each one is controlled indendently.

Here's an example from the script that you should modify to match how the instance of ColdFusion is configured on JRun:

#------- CUSTOMIZE HERE ---------------
#
#change the following few settings as needed
RUNTIME_USER=""nobody""
JAVA_HOME="/opt/jrun4/jre"
JAVA_EXECUTABLE="/opt/jrun4/jre/bin/java"
#
#change JRun instance name here
#original multiserver cfmx will be "cfusion"
JRUN_INSTANCE="cfusion"
#
#change JRun root directory here
JRUN_DIR="/opt/jrun4"
#
#change ColdFusion war or ear location here.
#for example look in $JRUN_INSTANCE... what do you see?
#original multiserver will be "cfusion-ear/cfusion-war",
#but if you create new instance and deploy cf as war,
#will be "cfusion-war" if you extracted cfusion.war into cfusion-war directory
#CFMX_ARCHIVE="cfusion-war"
CFMX_ARCHIVE="cfusion-ear/cfusion-war"
#
#these should be ok as is so don't change
DOCROOT="${JRUN_DIR}/servers/${JRUN_INSTANCE}/${CFMX_ARCHIVE}"
CF_DIR="${JRUN_DIR}/servers/${JRUN_INSTANCE}/${CFMX_ARCHIVE}/WEB-INF/cfusion"
#------- END CUSTOMIZATION -----------

And here is an example of calling the service command from root's home directory to start and stop the cfusion instance that is default with CFMX 7 Multiserver:

[root@Aneto ~]# service jruncfmx7multi start
Starting ColdFusion MX server instance cfusion on JRun ...
The ColdFusion MX server instance cfusion on JRun is starting up and will be available shortly.
======================================================================
ColdFusion MX server instance cfusion on JRun has been started.
ColdFusion MX server instance cfusion on JRun will write logs to
/opt/jrun4/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/logs/cfserver.log
======================================================================
[root@Aneto ~]# service jruncfmx7multi stop
Stopping ColdFusion MX server instance cfusion on JRun, please wait
Stopping cfusion server..stopped
ColdFusion MX server instance cfusion on JRun has been stopped
[root@Aneto ~]#

Finally, here's output from /var/log/messages that demonstrates three types of ColdFusion instances started on a system reboot:

[root@Aneto ~]# tail -500 /var/log/messages | grep jrun | grep succeed
Jul 15 15:31:31 Aneto rc: Starting jruncfmx61war: succeeded
Jul 15 15:31:44 Aneto rc: Starting jruncfmx7multi: succeeded
Jul 15 15:31:57 Aneto rc: Starting jruncfmx7war: succeeded
[root@Aneto ~]#

These scripts are currently provided as is, without warranty. Use at your own risk. I have opened a bug report to get boot scripts added to these types of ColdFusion configurations during the installation, and these boot scripts are provided as experimental only, but I have tested them thoroughly on Linux and they work well for me. Frankly, I'm not sure how to add boot scripts on Solaris, but I speculate that these will work well there, too, once I figure that out.

 


Comments

Cheers Steven!

I will give these a go when i get into the office on monday. We are running an internal server on Fedora4, ill let you know how it goes.

Thank you so much for your help


Echoing Pat's thanks, please accept ours also Steven. The timing here could not be better, I am in the throes of a Linux install to test a new commercial CF web site before launch.


Hi Steven

works a treat on my fedora box. However, one thing ive notice now is if i do a PS -A or view the running processes via webmin there is a stack of

'/opt/jrun4/bin/jrun -nohup -start cfusion' each reporting about 461972 kB of memory used. Although the total amount of memory available on the box is still the same as it used to be.

I read somewhere in the apache docs that it does a similar thing creating a heap of threads to handle requests.

what is it in your script that causes it to fire multiple threads ? and how come it doesnt do this when booting from the command line ?


What you have observed is normal for Linux. You see, the ps command on Linux shows all the OS threads that run within a process (not to be confused with JVM threads inside the JVM process), whereas ps on Unix shows only the processes not the threads.

So a ColdFusion process on Linux will usually show up with 10-50 "processes" when using the ps command.


Pat, I see what you refer to now.

ColdFusion MX 7 Server Configuration will show lots of "processes" (OS threads) whether you start it from the ColdFusion bin directory with "./coldfusion start" or as a Service with "service coldfusionmx7 start". Again, its considered ok for this because the ps command shows OS threads inside each matching process, not just the process themselves.

But I noticed that starting ColdFusion on JRun from the bin directory showed only 2 matching processes whereas starting it with these scripts showed the long list of matching "processes" instead.

I made these ColdFusion for JRun scripts by starting with a ColdFusion Server Configuration start script, so yes I think there is something in the script that does not "mask" all the threads in the process, and I think that starting jrun from its bin directory somehow does mask all that.

I can't explain the difference right now, except to say that you shouldn't worry about it. The memory footprint shown for each matching line returned from ps is the footprint for the thread's parent process, so you'll see lots of threads from ps that have identical memory footprint under RES. The threads all share that memory footprint of the parent process.


Awesome... I've been looking for this!

Thanks so much Steven!


Your script works great, however you might want to modify the grep statements to search along word boundaries for the $JRUN_INSTANCE. I created two instances on my machine, one called "cfusion" the other called "cfusiontest".

I ran into problems starting and stopping the cfusion instance, if the cfusiontest was running, because the "ps -ef | grep cfusion" test would return the cfusiontest processes, which caused the script to assume the instance was already running or could not be stopped. Changing the grep statements to "ps -ef | grep \\b$JRUN_INSTANCE\\b" seems to have solved the problem.


Thanks for the heads up. Here's the officious warning then until I take another look at it:

WARNING: Make sure that any instance name is not a subset of another instance name.


I've found out why it wasn't working for me. I downloaded the scripts to my Windoze computer and modified it using my computer before uploading it. So, that added a CR LF to each line break. Since Linux only understood CR, that was causing the problem.

When I downloaded the scripts directly to my server and modified it there using "vi", it works perfectly.

Thanks for the great script, Steve.

Cheers!


Note that if you want each JRun server instance to use different JVM settings rather than all reading the same jvm.config file, you'll have to create new servername_jvm.config files as modified copies of the original jvm.config and then add the switch -config "/path/to/the/servername_jvm.config" to the init script


 

 

Calendar

 
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Search This Site

 
This is an exact search only

About This Site

 
I live west of Boston and work as a Software Engineer with ColdFusion and Flex, specializing in Linux. Recently I graduated in Professional Digital Photography from CDIA.
More about me

Recent Entries

 
A ColdFusion Trick for Lost D..
Starting ColdFusion9 Solr: Us..
Adobe LiveCycle DataServices ..

Recent Comments

 
Posted By Aaron Longnion:
Thanks Steven, I just ran into this problem, remembered your tweet about it, and found your blog on it. :)

Posted By srinyvas:
Hai, This information is very useful and i like your excellent writing skill. Can i copy this Content to my website top management colleges ...

Posted By Steven Erat:
@Wade - Glad I could help! Thanks for letting me know it worked for you too.

recently played

 
The Candid Frame #70 - Greg Gorman
by Ibarionex R. Perello
on The Candid Frame: A Photography Podcast

now playing, a plug-in for itunes

Categories

 
RSS Adobe (34)
RSS Bicycling (9)
RSS Blogging (39)
RSS Books (13)
RSS Breeze (13)
RSS CFMX Podcasts (10)
RSS ColdFusion (427)
RSS Computer Technology (51)
RSS Events (26)
RSS Flex (20)
RSS Gadgets (10)
RSS HiTech Industry (16)
RSS Java (25)
RSS Learning (57)
RSS Linux (70)
RSS Mac OS X (22)
RSS Macromedia (27)
RSS Meetup (35)
RSS New England (62)
RSS Odds & Ends (25)
RSS Outdoors (32)
RSS Personal (29)
RSS Photography (111)
RSS Photoshop (29)
RSS Podcasts (18)
RSS Rants (19)
RSS Restaurants (8)
RSS Science (34)
RSS Spain (16)
RSS Travel (42)
RSS Twitter (10)
RSS Video (20)
RSS Webcam (3)
RSS Writing (10)

Blogs I Read

 
Terrence Ryan
Ben Forta
Ray Camden
Kinky Solutions
Dan Vega
Gary Gilbert
Simeon Bateman
Red Hat Blogs
O'Reilly Digital Media
O'Reilly Radar
John Nack
The Strobist
Scott Kelby
Matt Kloskowski
Joe McNally
Digital Photography School
Engadget
Science Blog

RSS

 


Add to Google
Add to My Yahoo!

Aggregated By

 


Consumed By Feed-Squirrel.com
Aggregated by ColdFusionBlogger.org

Credits and Stuff

 
BlogCFC - Free ColdFusion Powered Blog Software
CJM Group - ColdFusion Website Hosting


 
 
blog | photos | flickr | referers | webcam | stats | about | contact
 
Copyright © 2010 Steven Erat. All rights reserved.
This is a personal weblog. The opinions expressed here represent my own and not those of my employer