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

Failover for scheduled task

Community Beginner ,
Jul 22, 2009 Jul 22, 2009

hi,

i have 1 istance with some scheduled task. Now i'd like to have another server with another CF istance running in "cold backup", ready to accept request when the first server doesn't respond anymore.

The problem is with the scheduled task, if i configure them in both istances they will run twice.. There is a way (or a workaround) to launch only once the scheduled task?

i thought a workaround..

a shell script that check the virtual IP (that switch between two servers), if is assigned to his server, then will launch a wget of the scheduled task URL otherwise will exit.

In CF8 i have seen that i can suspend a scheduled task.. there is a way to launch command line a command to enable/disable scheduled task? some parameter in the jrun?

There are other solutions/workaround?

thanks in advance

1.4K
Translate
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
Guest
Jul 22, 2009 Jul 22, 2009

The adminapi doesn't hook into scheduled tasks.

What you might consider is a simple table that you can time-stamp and read from in your scheduled task. If a certain amount of time has passed (whatever you deem unreasonable) then the second server can kick off it's task, otherwise it will simply skip processing.

I.E.

<cfquery name="qryGetLastTimeRan">

     SELECT last_run_time

     FROM heartbeat

</cfquery>

<cfif DateDiff("n",qryGetLastTimeRan.last_run_time, Now()) GT 30>

     DO PROCESSING

     POSSIBLY ALERT THAT SERVER 1 IS UNRESPONSIVE

     ETC...

</cfif>

Just a quick and dirty solution...

Translate
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
Community Beginner ,
Jul 22, 2009 Jul 22, 2009

thanks for the proposal.. but are you sure this will work?

if i well understood, i will have server 1 with my scheduled task, and server 2 with scheduled your script.

when your script will run it will use the jrun of the second server and the qryGetLastTimeRan.last_run_time will simply check the last run of your script and not of my 1st server scheduled task..

i'm right?

Translate
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
Guest
Jul 22, 2009 Jul 22, 2009

You would end up having the same scheduled task on both servers however, it would be slightly different:


(SERVER 1)


<!---


    YOUR CODE FOR THE TASK GOES HERE


-->


<cfquery>

    UPDATE heartbeat

    SET last_run_time = <cfqueryparam value="#CreateODBCTime(Now())#" CFSQLType="CF_SQL_TIME">

</cfquery>


(SERVER 2)

<cfquery name="qryGetLastTimeRan">

     SELECT last_run_time

     FROM heartbeat

</cfquery>

<cfif DateDiff("n",qryGetLastTimeRan.last_run_time, Now()) GT 30>

<!---


    YOUR CODE FOR THE TASK GOES HERE


-->

</cfif>

(WHAT THIS WILL DO)

As long as the scheduled task is ran successfully on 1, it will update the time stamp. Server 2 runs the process and verifies that 1 ran. If not, then 2 will run the process. You can code two to send out notifications that one is down etc... or just run the process. It's not a perfect solution, but it should get you through.

NOTE:

The DateDiff() checks for a thirty minute delay. You need to adjust this to what you deem appropriate and you need to make sure to stagger the scheduled tasks on the two ColdFusion instances.

Translate
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
Community Beginner ,
Jul 23, 2009 Jul 23, 2009
LATEST

the two scheduled task (on server1 and server2) don't have different timing? doesn't each scheduled task check/update time stamp on its server?

"As long as the scheduled task is ran successfully on 1, it will update the time stamp."

doesn't it will update the time stamp on server1? how can the server2 scheduled task see the server1 time stamp?

"<cfif DateDiff("n",qryGetLastTimeRan.last_run_time, Now()) GT 30>"

doesn't check the time stamp on server2?

Translate
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