Server.cfc

If you find you need for some initialization to be performed when the server starts up you can hook into the Server.cfc functionality. This is a CFC that OpenBD will look for and execute before it starts accepting requests from clients.

By default, OpenBD looks for the CFC in the root of the app folder /Server.cfc and like the Application/cfc/cfm the case of this file matters. You can change the location of this file by setting it in the bluedragon.xml file. For example, the following snippet from that bluedragon.xml is below:

<server>
  <system>
    <servercfc>/WEB-INF/Server.cfc</servercfc>
    ...
  </system>
  ...
</server>

This CFC is a standard CFML component that obeys all the usual rules. The only requirement is that you must provide an implementation for the onServerStart method. This is the method that OpenBD will locate and execute when the engine first starts up.

<cfcomponent>

  <cffunction name="onServerStart">
    // you startup code here
  </cffunction>

</cfcomponent>

Any errors that occur here will be logged in the bluedraogn.log with the corresponding error dump written out in the usual error folder.

There are very little restrictions as to what you can do in this file. Naturally because the engine is calling this file, there is no output associated with it. Also many of the tags/functions that are geared towards web processing (for example set status code) will have no effect.

This is a particular useful feature for setting up global objects that only need to initialised once and can be used throughout every application and page request.