Schedule recovery handler template

Script windmill Verified

by hugo697 ยท 8/18/2023

The script

Submitted by hugo697 Bun
Verified 606 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
}
Other submissions
  • Submitted by hugo697 Deno
    Created 933 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