Coder Social home page Coder Social logo

rbrahul / deno_cron Goto Github PK

View Code? Open in Web Editor NEW
99.0 99.0 2.0 85 KB

A cron Job scheduler for Deno that allows you to write human readable cron syntax with tons of flexibility

License: MIT License

TypeScript 100.00%
cron cronjob crontab deno scheduler

deno_cron's People

Contributors

rbrahul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

iurypiva v-mu

deno_cron's Issues

seconds are minutes?

Hey,
in the doc you say it starts with seconds but the cron is run every minutes.

deno.json : "cron": "https://deno.land/x/deno_cron/cron.ts",

deno --version:

deno 1.39.1 (release, x86_64-unknown-linux-gnu)
v8 12.0.267.8
typescript 5.3.3
    import { cron } from 'cron';

    cron('* * * * *', () => {
        console.log(new Date()); // every minutes not seconds like documented
    });

Timezone

Thanks for your module.

What about adding timezone? Inspired by https://github.com/kelektiv/node-cron.

Timezone is important because you can execute jobs on machines with a timezone different with respect to the job.

RFC for cron API: cron(schedule, job, timezone):

// Run Job at 9a.m. NY time 
cron('0 0 9 * * *', () => {
    checkStock();
}, "America/New_York"});
export const cron = (schedule: string = '', job: JobType, timezone: string) => {
// I suppose we need to change `schedules` Map, adding timezone info
...

Then in executeJobs the validation is done for the following date:

 schedules.forEach((jobs, schedule, timezone) => {
   const date = new Date().toLocaleString("en-US", {timeZone: timezone});
...

What do you think?

I noticed toLocaleString doesn't work. See denoland/deno#1636
Compare the following snippet in deno and in node:

var asiaTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Shanghai"});
console.log('Asia time: '+ (new Date(asiaTime)).toISOString());

Assertion Error on Timer

I am getting this error at intervals. the error seem to come from clearInterval Function on driver.
`Any lead in resolving it permanently? Thanks

    at assert (deno:ext/timers/01_timers.js:40:13)
    at setGlobalTimeout (deno:ext/timers/01_timers.js:349:5)
    at setOrClearGlobalTimeout (deno:ext/timers/01_timers.js:393:7)
    at unschedule (deno:ext/timers/01_timers.js:442:9)
    at clearTimer (deno:ext/timers/01_timers.js:564:5)
    at clearInterval (deno:ext/timers/01_timers.js:581:5)
    at https://deno.land/x/[email protected]/cron.ts:118:13
    at fire (deno:ext/timers/01_timers.js:477:7)
    at handleTimerMacrotask (deno:ext/timers/01_timers.js:338:7)
Watcher Process finished. Restarting on file change...```

Caught errors cause cronjob to die permanently

hii there,

I have some cronjobs using this that rely on fetch to get some data from external APIs.
However, sometimes, the internet is offline during the moments these fetches happen.
I cleanly catch these errors like this:

cron('* * * * *', async () => {
  try {
    await this.update();
  } catch(e) {
    error(`Could not update Azur Lane server status: ${e.message}`);
  }
});

The console shows that it was caught just fine:

[ERR  @ 2021/05/20 13:25:05] Could not update Azur Lane server status: error sending request for url (http://blhxusgate.yo-star.com/?cmd=load_server?): error trying to connect: dns error: Device or resource busy (os error 16)

But the cronjob is never run after this again (the only way to fix it, is to re-register the job in the code or restart the Deno process all together).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.