Server.cfc

A component whose methods run when the server starts, before any application loads. Use it for server-wide setup that does not belong to a single application, such as setting server scope variables, configuring logging or scheduling tasks. It is separate from Application.cfc.

In ColdFusion, Server.cfc is disabled by default. Enable it in the ColdFusion Administrator under Server Settings > Settings, where you can also change its location (the default is Server.cfc in the web root) and set a timeout. The code cannot use the application or request scopes, or features that need the server to be fully started, such as a cfhttp request to the same server. Startup errors are logged in server.log, with details in exception.log.

component { function onServerStart() { } }

Server.cfc

onServerStart function

Runs once when the server starts. In ColdFusion it takes no arguments.

In Lucee it receives a reload argument, which is false on the first start and true when the server configuration is updated in the Lucee Administrator or an extension is installed.

onBuild function

Lucee 6.1.1+ Runs when Lucee is started in build mode, by setting the environment variable LUCEE_BUILD or LUCEE_ENABLE_WARMUP to true.

Compatibility

Lucee:

Lucee also calls onBuild in Lucee 6.1.1+, and passes a reload argument to onServerStart.

Links more information about Server.cfc

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub