I'm writing a database load script in ColdFusion. It loads about 150,000 records across a dozen tables. I am running the script through a web browser request. Is there any way to kill the process once I've requested the page? I can stop the page in the browser, but the database inserts continue on the backend until the script has completed, which makes the debugging process very slow since I have to run the entire script each time. Is there anything I can do through the Java backend?
The environment I'm in is ColdFusion 8 running through IIS. I have the performance monitoring disabled, but I'd like to be able to mimic the ability to kill jobs as in the performance monitor.
I'd tried to make something like Unix pid-file: your script should periodically (maybe each 10/100/1000 iterations) check the availability of some file in the filesystem and stop executing if it contains certain value, or maybe if exists or not at all.
Of course, this can be a field in the database, variable in application scope (with appropriate locking strategy), or anything you find suitable.
You also need second script which will be changing the state of your "pid-object". This can be as simple as another .cfm you can pull with the browser.
In the loop through the 150,000 records can you just stop it at whatever number you think is appropriate. Set a counter variable and whenever it gets there in the loop just <cfabort>
or <cfbreak>
.
You will probably want to run the process using cfthread.
Start your process like...
<cfthread name="myThread" action="run">
...Your loop to insert into database....
</cfthread>
Then you can kill the thread by using...
<cfthread action="terminate" name="myThread"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With