agent starting :D
This commit is contained in:
@@ -18,9 +18,10 @@ export interface JobInfo {
|
||||
|
||||
// Store running cronjobs
|
||||
export const runningCrons: Record<string, Cron> = {};
|
||||
const log = createLogger({ module: "system", subModule: "croner" });
|
||||
|
||||
// how to se the times
|
||||
// * ┌──────────────── (optional) second (0 - 59) \n
|
||||
// * ┌──────────────── (optional) second (0 - 59)
|
||||
// * │ ┌────────────── minute (0 - 59)
|
||||
// * │ │ ┌──────────── hour (0 - 23)
|
||||
// * │ │ │ ┌────────── day of month (1 - 31)
|
||||
@@ -30,6 +31,8 @@ export const runningCrons: Record<string, Cron> = {};
|
||||
// * │ │ │ │ │ │ ┌──── (optional) year (1 - 9999)
|
||||
// * │ │ │ │ │ │ │
|
||||
// * * 05 * * * * *
|
||||
// note that when leaving * anywhere means ever part of that. IE * in the seconds part will run every second inside that min
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name Name of the job we want to run
|
||||
@@ -43,7 +46,6 @@ export const createCronJob = async (
|
||||
) => {
|
||||
// get the timezone based on the os timezone set
|
||||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const log = createLogger({ module: "system", subModule: "croner" });
|
||||
|
||||
// Destroy existing job if it exist
|
||||
if (runningCrons[name]) {
|
||||
@@ -124,11 +126,19 @@ export const removeCronJob = (name: string) => {
|
||||
export const stopCronJob = (name: string) => {
|
||||
if (runningCrons[name]) {
|
||||
runningCrons[name].pause();
|
||||
log.info(
|
||||
{},
|
||||
`${name} was just stopped either manually or due to a setting change.`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const resumeCronJob = (name: string) => {
|
||||
if (runningCrons[name]) {
|
||||
runningCrons[name].resume();
|
||||
log.info(
|
||||
{},
|
||||
`${name} was just restarted either manually or due to a setting change.`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user