• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ColdFusion startup script?

Explorer ,
Apr 27, 2010 Apr 27, 2010

Copy link to clipboard

Copied

I'm running CF8 Server under Windows. I have an application, MyApplication, in which, for a variety of reasons, I refresh some application-scope arrays on a schedule. To simplify just a bit, there is a ColdFusion script that runs each hour, and in the script I have

<lock MyApplication scope>

     generate array A1

     generate array A2

     ...

     generate array An

<unlock MyApplication scope>

This works just fine -- except that if I have to restart ColdFusion or reboot the server, the application throws errors until I can manually execute the script.

Is there a way of having ColdFusion execute this script upon startup? If so, would I have to make any changes to the script (for example, insert a server-level lock inside the application-level lock, and/or address all the variables as MyApplication.application.A1, MyApplication.application.A2, etc)?

If not, is there another way of achieving the goal? For example, could I do something like this in application.cfm:

<test for existence of A1 or A2 or ... or An>

     <if at least one of them does not exist>

          <lock application scope>

               <lock server scope>

                    generate array A1

                    generate array A2

                    ...

                     generate array An

               <unlock server scope>

          <unlock application scope>

     <end if>

<end test>

Thanks for any help/insight.

TOPICS
Advanced techniques

Views

719

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 27, 2010 Apr 27, 2010

Copy link to clipboard

Copied

LATEST

Write your function in a either a separate .cfm or .cfc file.  Call this function in the onApplicationStart function of your Application.cfc file.  Also call it in the script that runs every hour.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation