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 developer advocate for HERE Technologies. He focuses on JavaScript, serverless 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