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.
Copy link to clipboard
Copied
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.