Skip to main content
Participant
Jun 12, 2023 11:57 AM UTC
Question

Application not starting the Server.cfc which has the onServerStart() method

Hi, 

I am running my coldfusion application via docker, the application has a onServerStart() method in a file called Server.cfc which lies inside the webroot of our coldfusion project, when building the container the Server.cfc does not get triggered, although I can do it from the admin console(that works) but is there any other way to do the same. 

I have also tried to create an object of Server.cfc and calling from the application.cfc, but using that the control goes into the server.cfc method but does not initialize the server with the details.

Thanks in advance.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    BKBK
    Community Expert
    Community Expert
    Jul 14, 2024 7:35 PM UTC
    quote

    Hi, 

    I have also tried to create an object of Server.cfc and calling from the application.cfc


    By @anirbang43046357

     

    You should not be doing that, as it goes against the reason why Server.cfc exists. OnServerStart is an event-handler. It fires automatically, if enabled. ColdFusion is the one that internally instantiates the Server object, not you, the developer.
    Expecting the Application to start the Server is analogous to expecting the tail to wag the dog.

     

    quote

    ... when building the container the Server.cfc does not get triggered, although I can do it from the admin console(that works) but is there any other way to do the same. 

     

    The usual way to trigger onServerStart is indeed through the ColdFusion Administrator, as Dave has said. I saw his post only after I posted. So I had to modify my post to avoid repeating his suggestions.

     

    Follow the instructions he has provided, and things should work out.

     

    Translate
    Community Expert
    Jul 14, 2024 6:36 PM UTC

    Did you check your server.cfc location in CF Administrator?

     

    https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/onserverstart.html

     

    Dave Watts, Eidolon LLC 

    Translate
    Dave Watts, Eidolon LLC
    dejank52055655
    Inspiring
    Jul 14, 2024 3:00 PM UTC

    Hi, I'm guessing this is customtag. Did you ever find the solution?

    Translate
    dejank52055655
    Inspiring
    Jul 14, 2024 7:53 PM UTC

    Dave and BKBK suggestions solutions worked for me.

    Translate