0
Schedule recovery handler template
One script reply has been approved by the moderators Verified
Created by hugo697 193 days ago Viewed 92 times
0
Submitted by hugo697 Deno
Verified 193 days ago
1
export async function main(
2
  path: string, // The path of the script or flow that errored
3
  is_flow: boolean, // Whether the runnable is a flow
4
  schedule_path: string, // The path of the schedule
5
  error: object, // The error details
6
  error_started_at: string, // The start datetime of the latest job that failed
7
  success_times: number, // The number of times the schedule succeeded before calling the recovery handler.
8
  success_result: object, // The result of the latest successful job
9
  success_started_at: string // The start datetime of the latest successful job
10
) {
11
  console.log(
12
    `Schedule ${schedule_path} recovered ${
13
      success_times > 1 ? success_times + " times in a row" : ""
14
    }\n${is_flow ? "Flow" : "Script"}: ${path}`
15
  );
16
  console.log(`Last failure at ${error_started_at}:`, error);
17
  console.log(`Last success at ${success_started_at}:`, success_result);
18
  return error;
19
}
20