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:
public function onServerStart() {
writelog(file="application", text="Starting up at #now()#");
}
}
component {
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.