Skip to main content
Participant
May 5, 2008
Question

Run a CFM/CFC at server start

  • May 5, 2008
  • 2 replies
  • 444 views
I am wondering if it is possible to let a CFM run *before* the CF8 server starts to accept other requests.

I would like to initialize a CFC in a server scope variable so i would not have to do that 500000x per day. I could put a IsDefined() block around every call, but having the server variable up and available before any other requests pour in would be too cool.

Any ideas?
    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    May 5, 2008
    As Azadi says, onApplicationStart is sufficient for what you describe.

    Inspiring
    May 5, 2008
    huh? and what would process a cfm if cf server is not running?

    would not an Application-scoped cfc suffice? put the instantiation code
    in onApplicationStart method of Application.cfc...

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    smrchAuthor
    Participant
    May 5, 2008
    Hehe, i know you can't run CFM if the CF server is not up, but i was wondering if there is a way to populate some the server scope before the other CFM files run. That way i don't have to do checks everytime if they exist/if not populate them etc.
    When i start / restart the server there will be a good queue of requests all needing this server scope. They would start running near simultaneously creating race conditions on populating that scope.

    So i need like a 'onServerStart' Method, a autoexec.bat, system.ini whatever for the CF server. Something that runs before other requests run.