Code Monkey home page Code Monkey logo

meteor-cron-jobs's Introduction

CRON Jobs for meteor

301: This package is moved to the main repository of NPM version, but still can be installed via Atmosphere as Meteor package!

Install:

meteor add ostrio:cron-jobs

Looking for NPM version? - Go to JoSk package

Import:

import { CRONjob } from 'meteor/ostrio:cron-jobs';

Known Issues:

Error: Can't wait without a fiber

Can be easily solved via "bounding to Fiber":

const bound = Meteor.bindEnvironment((callback) => {
  callback();
});

const db   = Collection.rawDatabase();
const cron = new CRONjob({db: db});

const task = (ready) => {
  bound(() => {
    ready();
  });
};

cron.setInterval(task, 60 * 60 * 1000, 'task');

meteor-cron-jobs's People

Contributors

dr-dimitru avatar lesstoks avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

meteor-cron-jobs's Issues

Fix confusing `setImmidiate` section in docs, gives an error when used

Hi! Great package for CRON jobs in meteor

The setImmidiate section of the docs somehow gives an error when used.

CRON.setImmidiate is not a function.

However, upon checking the JoSk package index.js , it turns out that the function is setImmediate. The docs should be edited with the correct method signature so as not to confuse other developers. Can also apply in JoSk package

Execute a task at a specific time of the day, day of the week, etc.

We previously used SyncedCron (https://github.com/percolatestudio/meteor-synced-cron) but it is no longer maintained and we noticed it to, at times, skip some of our tasks without any notification.

Hence we intend to use this package for our tasks, some of which simply need to run every x minutes, but other need to run at a specific point in time (for instance every day at 04:00).

Any suggestions for implementing such a feature, or is this already available?

Try to use different instances

Hi!
With some other tasks your cron works nicely, but with next primitive task for cleaning cart from outdate items:

 const cartItems = (ready) => {
    bound(() => {
        ready();
        // some cleaning code
    });
};
  const testCartItems = cartItemsCron.setInterval(cartItems, 20 * 1000, 'cartItems');

i have problems:

[josk] [josk] [cart-itemssetInterval] Something went wrong with one of your tasks is missing.
          Try to use different instances.
           It's safe to ignore this message.
          If this task is obsolete - simply remove it with `JoSk#clearTimeout('cart-itemssetInterval')`,
          or enable autoClear with `new JoSk({autoClear: true})`

Please help me, thanks

upgraded from 2.2.1 to 2.3.0: TypeError: CRONjob is not a constructor

Hi!
The devil pulled me to meteor update and now i get in my project:
TypeError: CRONjob is not a constructor
I tried
meteor remove ostrio:cron-jobs
and
meteor add ostrio:[email protected]
but this don't help me, no matter:
ostrio:cron-jobs added, version 2.3.0
Also linter says:
import {CRONjob} from 'meteor/ostrio:cron-jobs'; //Module is not installed
although at the same time your other packages (FlowRouter, Meta, Title) without errors.

Can you help me?
Thanks!

Problem with MongoDB cluster

Hello,

if im using connection string that contains Mongo Cluster
ex mongodb://developers:[email protected]:27017,10.0.2.250:27017/myproject-dev?replicaSet=mongo_replication, there is problem in situation when primary MongoDB is down.

In normal case, Meteor reconnect app to other Cluster client.
If there is CronJob integrated, instance fall down..

I have this source code

  const db = Meteor.users.rawDatabase();
  const cron = new CRONjob({db, resetOnInit: true, autoClear: true});

  const bound = Meteor.bindEnvironment((callback) => {
    callback();
  });


  const taskSyncTask = function (ready) {
    bound(() => {
      orderWorkerInstance.checkOrdersWaitingForRaynetSyn();
      ready();
    });
  };

With this error message:

20180607-13:23:28.557(2)? (STDERR) [object Object]
W20180607-13:23:28.559(2)? (STDERR)     at _debug (/Users/markus/.meteor/packages/ostrio_cron-jobs/.2.2.0.1aqpnqj.oetd++os+web.browser+web.cordova/npm/node_modules/josk/index.js:3:11)
W20180607-13:23:28.560(2)? (STDERR)     at collection.findOneAndUpdate (/Users/markus/.meteor/packages/ostrio_cron-jobs/.2.2.0.1aqpnqj.oetd++os+web.browser+web.cordova/npm/node_modules/josk/index.js:80:13)
W20180607-13:23:28.561(2)? (STDERR)     at handleCallback (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/utils.js:120:56)
W20180607-13:23:28.561(2)? (STDERR)     at /Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/collection.js:2492:22
W20180607-13:23:28.562(2)? (STDERR)     at handleCallback (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/utils.js:120:56)
W20180607-13:23:28.563(2)? (STDERR)     at /Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/db.js:314:20
W20180607-13:23:28.563(2)? (STDERR)     at /Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:469:18
W20180607-13:23:28.563(2)? (STDERR)     at _combinedTickCallback (internal/process/next_tick.js:131:7)
W20180607-13:23:28.564(2)? (STDERR)     at process._tickDomainCallback (internal/process/next_tick.js:218:9)
W20180607-13:23:28.565(2)? (STDERR) { MongoError: interrupted at shutdown
W20180607-13:23:28.566(2)? (STDERR)     at Function.MongoError.create (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/error.js:31:11)
W20180607-13:23:28.567(2)? (STDERR)     at /Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:497:72
W20180607-13:23:28.567(2)? (STDERR)     at authenticateStragglers (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:443:16)
W20180607-13:23:28.567(2)? (STDERR)     at Connection.messageHandler (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:477:5)
W20180607-13:23:28.568(2)? (STDERR)     at Socket.<anonymous> (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/connection.js:333:22)
W20180607-13:23:28.568(2)? (STDERR)     at emitOne (events.js:116:13)
W20180607-13:23:28.569(2)? (STDERR)     at Socket.emit (events.js:211:7)
W20180607-13:23:28.569(2)? (STDERR)     at addChunk (_stream_readable.js:263:12)
W20180607-13:23:28.569(2)? (STDERR)     at readableAddChunk (_stream_readable.js:250:11)
W20180607-13:23:28.570(2)? (STDERR)     at Socket.Readable.push (_stream_readable.js:208:10)
W20180607-13:23:28.570(2)? (STDERR)     at TCP.onread (net.js:594:20)
W20180607-13:23:28.570(2)? (STDERR)   name: 'MongoError',
W20180607-13:23:28.570(2)? (STDERR)   message: 'interrupted at shutdown',
W20180607-13:23:28.571(2)? (STDERR)   operationTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1528370607 },
W20180607-13:23:28.571(2)? (STDERR)   ok: 0,
W20180607-13:23:28.571(2)? (STDERR)   errmsg: 'interrupted at shutdown',
W20180607-13:23:28.572(2)? (STDERR)   code: 11600,
W20180607-13:23:28.572(2)? (STDERR)   codeName: 'InterruptedAtShutdown',
W20180607-13:23:28.572(2)? (STDERR)   '$clusterTime': 
W20180607-13:23:28.573(2)? (STDERR)    { clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1528370607 },
W20180607-13:23:28.573(2)? (STDERR)      signature: { hash: [Object], keyId: [Object] } } }
W20180607-13:23:28.573(2)? (STDERR) Uncaught Exception [josk] [General Error during runtime]: MongoError: interrupted at shutdown
W20180607-13:23:28.574(2)? (STDERR) Error: [josk] [General Error during runtime]: MongoError: interrupted at shutdown
W20180607-13:23:28.574(2)? (STDERR)     at collection.findOneAndUpdate (/Users/markus/.meteor/packages/ostrio_cron-jobs/.2.2.0.1aqpnqj.oetd++os+web.browser+web.cordova/npm/node_modules/josk/index.js:81:19)
W20180607-13:23:28.574(2)? (STDERR)     at handleCallback (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/utils.js:120:56)
W20180607-13:23:28.575(2)? (STDERR)     at /Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/collection.js:2492:22
W20180607-13:23:28.575(2)? (STDERR)     at handleCallback (/Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/utils.js:120:56)
W20180607-13:23:28.575(2)? (STDERR)     at /Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/db.js:314:20
W20180607-13:23:28.576(2)? (STDERR)     at /Users/markus/.meteor/packages/npm-mongo/.2.2.34.qztsqr.w4m9++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:469:18
W20180607-13:23:28.576(2)? (STDERR)     at _combinedTickCallback (internal/process/next_tick.js:131:7)
W20180607-13:23:28.576(2)? (STDERR)     at process._tickDomainCallback (internal/process/next_tick.js:218:9)
=> Exited with code: 1
W20180607-13:24:33.242(2)? (STDERR)           
W20180607-13:24:33.243(2)? (STDERR) /Users/markus/.meteor/packages/meteor-tool/.1.6.1.z27a56++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:313
W20180607-13:24:33.243(2)? (STDERR) 						throw(ex);
W20180607-13:24:33.244(2)? (STDERR) 						^
W20180607-13:24:33.244(2)? (STDERR) MongoError: connection 3 to 10.0.1.250:27017 timed out

Can you help me with this case ?
Thank you!

Exception in callback of async function: TypeError: ready is not a function

Hi, i'm trying to CRONize phone calls

const sendCall = function (phone,ready) {
    phone = "+38050XXXXXXXX";
    bound(() => {
        ready();
        Meteor.call("sendCall",phone);
    });
};
cron.setInterval(sendCall, 60 * 1000, 'sendCall'); 

I'm having an issue:

Exception in callback of async function: TypeError: ready is not a function

question

What is for ready() and how it works?

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.