Can you manually run your ColdFusion's onServerStart CFC?

This post is more than 2 years old.

Yes. Done. End of post. See ya. Ok - bad joke. Let me be a bit more verbose. Earlier today a user on Twitter asked if it was possible to manually run your ColdFusion's OnServerStart component. This is the component you register within your CF Admin to run on server startup, as I've done here:

Here is the CFC I wrote, which just does a simple log:

component {

public function onServerStart() {
	writelog(file="application", text="Starting up at #now()#");	


And the answer is - as I said above - yes. You can call it from any other CFM/CFC you wish:

<cfset myServer = new myServer()> <cfset myServer.onServerStart()>

The only thing to keep in mind is that - much like calling Application.cfc methods manually - your call will not be automatically single threaded as a "real" onServerStart call is. I have to say that I've yet to use this feature in production yet. Anyone else? Also - I want to give props to Daria for answering this on Stack Overflow as well.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Daria posted on 6/14/2011 at 11:24 PM

I use the server scope a lot to share what we'd normally think of as application scoped variables across the entire site. This is because of previous choices about how our site's application.cfm files were set up. So i use onServerStart() to initialize all the cached server scope data and use the method above when I need to reinitialize.

This is not the solution for everyone and i'd warn against using the server scope unless you have complete control over your ColdFusion server.

Comment 2 by Leo posted on 6/30/2011 at 12:58 AM

Great site and great articles! Will link you in the ColdFusion part of my site: