Saturday, July 31, 2010    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< Jun 2009 >>
S M T W T F S
  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        

Search

Categories
 • Acrobat (5) [RSS]
 • Adobe (96) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (66) [RSS]
 • AdobeMAX09 (39) [RSS]
 • AdobeMAX10 (7) [RSS]
 • AIR (233) [RSS]
 • Appearances (198) [RSS]
 • Books (78) [RSS]
 • CFEclipse (15) [RSS]
 • ColdFusion (1409) [RSS]
 • ColdFusion Builder (9) [RSS]
 • Data Services (36) [RSS]
 • Fish Tank (5) [RSS]
 • Flash (248) [RSS]
 • Flex (513) [RSS]
 • Home Automation (5) [RSS]
 • Jobs (119) [RSS]
 • JRun (14) [RSS]
 • Labs (47) [RSS]
 • LiveCycle (35) [RSS]
 • MAX (238) [RSS]
 • Mobile (138) [RSS]
 • Regular Expressions (18) [RSS]
 • RIA (21) [RSS]
 • SQL (42) [RSS]
 • Stuff (543) [RSS]
 • Tips (CF Studio) (80) [RSS]
 • Tips (CF) (795) [RSS]
 • Tips (Dreamweaver) (91) [RSS]
 • Tips (Flex Builder) (2) [RSS]
 • Using CF (164) [RSS]

Other BLOGs
 • Charlie Arehart
 • Lee Brimelow
 • Ray Camden
 • Christophe Coenraets
 • Sean Corfield
 • Mihai Corlan
 • Cornel Creanga
 • Mark Doherty
 • John Dowdell
 • Danny Dura
 • Enrique Duvos
 • Steven Erat
 • Kevin Hoyt
 • Serge Jespers
 • Adam Lehman
 • Duane Nickull
 • Miti Pricope
 • Andrew Shorten
 • Ryan Stewart
 • James Ward
 • Greg Wilson
 • Full As A Goog

RSS Feeds
 • Feed
 • Subscribe

Join my mailing list and find out about new books and other topics of interest.

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.

Viewing By Entry / Main
June 22, 2009

Executing Code On Server Startup

ColdFusion can execute code when an application starts and ends, when a session starts and ends, when a request starts and ends, and more. But what if you need to execute code when a server starts up? Granted, this is not a common use case, but when needed, we've had to use onApplicationStart for this, probably doing something like:

<cfif not IsDefined("SERVER.myVar")>
...
</cfif>

ColdFusion Centaur adds the ability to define code to be executed onServerStart.

By default this is a method named onServerStart in server.cfc. But, actually, it can be in any ColdFusion Component, including an Application.cfc. In ColdFusion Administrator you can point to the CFC and method to be invoked, and ColdFusion will execute the code on server start-up before processing any requests.

Comments
Ah the wonders of Centaur! I have a USE for this particular feature, too!
# Posted By Sid Wing | 6/22/09 8:03 AM
This release is shaping up to have some nifty features. Good on Adobe for implementing features that, you know, matter to developers.
# Posted By Paul | 6/22/09 10:55 AM
I suggest, create a CFML tamplate. Add a IF condition, if there is no defined "application.check" then run the code. Add this page to Scheduled Tasks ind ColdFusion. Schedule increment is 10sn

Simple and effectivly.
# Posted By Esref Atak | 6/23/09 4:19 PM
Another way is could be:

Add a Scheduled Task to Windows. Select the IE from list in wizard. Finish the wizard. Type to Run textbox like that:

C:\PROGRA~1\INTERN~1\IEXPLORE.EXE "http://localhost/runonstart.cfm";

Windows automatically runs your web page when Windows start.
# Posted By Esref Atak | 6/23/09 4:26 PM
Ben! Don't downplay the benefits and power of onServerStart. A lot of apps take an initial hit on the first request while all of the onApplicationStart initialization runs. onServerStart is the perfect opportunity to initialize all of the apps on the server and get the first-serve overhead out of the way so the first user doesn't feel it. It's Michael Jackson bad.
# Posted By David McGuigan | 6/26/09 3:21 AM

  © Copyright 1997-2009 Ben Forta, All Rights Reserved