|
|
Hello everyone,
It seems like a lot of people are having trouble getting ColdFusion 8 to run
and stay up during system startup on Mac OS X Server 10.5 (Leopard). I was
having the same problem but, after some research and I bit of experimentation,
I believe I have a solution that should work for those with a standard install;
so I wanted to share it.
First, The Problem:
I can't be 100% certain of this, but I believe the reason why the StartupItem
the ColdFusion 8 OS X installer creates in /Library/StartupItems doesn't work
for most people is that there's a bit of a conflict between the JBoss instance
that comes with OS X Server 10.5 to support the built-in blogs and wikis and
the JRun instance that drives CF8. This is evidenced by the issues with
/private/etc/apache2/httpd.conf that arise when you turn on/off wikis/blogs in
the Web section of the 10.5 Server Admin versus Adding/Removing the JRun
connector via the Webserver Connector Utility that comes with CF8.
If you pay close attention to how these apps modify the httpd.conf and make a
point of finalizing the Apache config via the Web section of the Server Admin
utility BEFORE you add the connector via the Webserver Connection Utility, you
should end up with an httpd.conf that is properly configured to support both
CF8 and the built-in wikis/blogs if Coldfusion isn't started until AFTER Apache
and JBoss are fully up and running.
This is no big deal if you're launching CF8 manually once the system is up and
running, but if ColdFusion tries to launch during system startup (which is what
the installed StartupItem has it do), it will crap out and not run again,
leaving you with Apache and JBoss but no CF/JRun by the time startup completes.
The Solution:
In Mac OS X 10.4 and up, StartupItems are not recommended for starting daemons
and other system-wide, persistent services. They've been replaced by launchd,
which is a sort of mix of cron and rc for all you old-school UNIX nerds (like
me). :)
launchd runs at system startup and looks for XML-based config files called
plists in certain locations to spawn such processes. In the case of CF8, the
most logical location for such a config file is /Library/LaunchDaemons, which
is reserved for third-party daemons not included with the OS.
There's a naming convention that Apple uses which indicates the source of the
daemon. For example, you'll find org.apache.httpd.plist in the
/System/Library/LaunchDaemons directory, which is the launchd config file for
the Apache web server, but the naming doesn't really matter as long as the
filename ends in .plist.
So, here's the launchd config I came up with for getting CF8 Standalone to run
and stay up at system startup. Just remove the
/Library/StartupItems/ColdFusion8 folder the CF installer created and put the
attached code (below my signature) in a file called com.adobe.coldfusion8.plist
in your /Library/LaunchDaemons directory and you should be golden.
Here's a breakdown of what this config is actually doing for those unfamiliar
with launchd plists:
<key>Label</key>
<string>ColdFusion8</string>
## Each launchd job has to have a unique name for identification purposes.
<key>UserName</key>
<string>admin</string>
## Indicates the user the job will run as. The mirrors the behavior of the old
StartupItem.
<key>RunAtLoad</key>
<true/>
## Forces the program (defined below) to run as soon as this config is loaded
(at system startup).
<key>AbandonProcessGroup</key>
<true/>
## This is necessary to keep the coldfusion8 process that the "coldfusion
start" script spawns running once said script finishes executing. Without this,
the coldfusion8 process will get killed by launchd after a few seconds, which
in turn will cause the job to restart; creating an infinite loop wherein CF8
keeps coming up for a few seconds under a different process ID before launchd
kills it.
<key>KeepAlive</key>
<true/>
## Causes the job to restart if the coldfusion8 process is killed/stopped.
This ensures that ColdFusion will keep attempting to load until it is
successfully up and running, even if something else kills it or causes it to
crash during the startup process as I suspect Apache/JBoss may be. The end
result is that coldfusion8 may spawn and die a few times while the system is
coming up, but it will eventually run and stay up after everything else is up
and running. A little sloppy I know, but it works.
<key>WorkingDirectory</key>
<string>/Applications/ColdFusion8/bin</string>
## Ensures that launchd changes to the ColdFusion8 bin directory before
running the "coldfusion" script.
<key>ProgramArguments</key>
<array>
<string>./coldfusion</string>
<string>start</string>
</array>
## Tells launchd to run the "coldfusion" script in the current directory (set
above) with the "start" argument.
---
Well, that's it. Hope this is useful info for everyone. Oh, and in case anyone
is wondering, I didn't have any luck using configs that explicitly wait for
Apache/JBoss to be up and running before attempting to launch CF at startup,
which is why I'm not 100% sure regarding exactly what causes it to fail when
launched during startup. Fortunately, this launchd config just keeps trying to
run it until it sticks and also conveniently re-runs it if it dies after the
system's been up for a while, which is good enough for me. Also, Apple's made
it clear that they want people to use launchd for this sort of stuff, so the
only real question for me is whether or not there's a better way to configure
the plist than what I've come up with here.
If anyone has any ideas about that, please share. :) I'm happy with the way
its working now, but I'm curious to see what others think about this technique.
Thanks,
Michael Shotter
President
Vortex Edge, LLC
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ColdFusion8</string>
<key>UserName</key>
<string>admin</string>
<key>RunAtLoad</key>
<true/>
<key>AbandonProcessGroup</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>/Applications/ColdFusion8/bin</string>
<key>ProgramArguments</key>
<array>
<string>./coldfusion</string>
<string>start</string>
</array>
</dict>
</plist>
|
|