var zxy = require('zxy-comm');

//初始化定时器
var jobObj = function () {
    var conf = arguments && arguments[0] && zxy.app.m_verify.isJson(arguments[0]) ? arguments[0] : {};
    var func = arguments && arguments[1] && typeof arguments[1] == 'function' ? arguments[1] : function () { };
    var params = arguments && arguments[2] ? arguments[2] : [];
    var name = arguments && arguments[3] ? arguments[3].toString() : 'default';
    var schedule = require('node-schedule');
    var rule = new schedule.RecurrenceRule();
    for (var key in conf) {
        rule[key] = conf[key];
    }
    schedule.scheduleJob(rule, function () {
        var current = new Date();
        console.info("run job " + name);
        func(params, name);
    });
}
exports.jobObj = jobObj;