Note: Despite being documented in this section of the manual, this onServerStart method is NOT a method of Application.cfc. See below for more details on where, why, and how to use this method.

ColdFusion now supports a CFC with an onServerStart method that runs only when the server starts. The onServerStart method takes no parameters, and is the only function in the CFC. The function is useful for application-independent tasks, such as instantiating the applications, configuring logging, or setting up the scheduler.
By default, ColdFusion looks for the onServerStart method in cf_webroot/Server.cfc. To specify a different filepath:

  1. Launch ColdFusion Administrator.
  2. Click ColdFusion Administrator Server Settings > Settings.
  3. Specify the absolute filepath under the web root on the Settings page such as c:\Server.cfc. Alternatively, you can use a dot-delimited path under the web root, such as a.b.Server.

    Note: If you use an absolute path, the filename must end with .cfc. If you use a relative path or dotted path, do not end the name with the .cfc suffix.

    You select an option on the Settings page to enable and disable the onServerStart method. By default, the method is disabled.
    You can also specify a timeout limit (in seconds) for the onServerStart method. The timeout limit determines the duration for which the method would be allowed to run during server start up. This setting can be specified in server.cfc.
    The onServerStart method can use most CFML features, but not any features that require full server start. For example, the method cannot use a cfhttp tag with a URL that specifies a location on the same server. You also cannot use Application or Request scope variables in the method.
    By default, all errors, including any serverCFC errors, are logged in <ColdFusion_home>/WEB-INF/cfusion/logs directory for standalone and <appserver_root>/logs directory for J2EE configurations. 
    You can also specify a different location for logging by configuring the log directory setting in ColdFusion Administrator > Debugging and Logging > Logging Settings.
    The server.log file contains server startup information. So,
    any server.CFC startup errors are logged in it, but for details
    about the error, you have to see the exception.log file. In addition,
    server startup information is logged in {appserver_root}/logs directory.
    For WebSphere, it is logged in the SystemOut.log file.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy