| 36 | |
| 37 | class Bree extends EventEmitter { |
| 38 | constructor(config) { |
| 39 | super(); |
| 40 | this.config = { |
| 41 | // We recommend using Cabin for logging |
| 42 | // <https://cabinjs.com> |
| 43 | logger: console, |
| 44 | // Set this to `false` to prevent requiring a root directory of jobs |
| 45 | // (e.g. if your jobs are not all in one directory) |
| 46 | root: resolve('jobs'), |
| 47 | // Set this to `true` to silence root check error log |
| 48 | silenceRootCheckError: false, |
| 49 | // Set this to `false` to prevent requiring a root directory of jobs |
| 50 | doRootCheck: true, |
| 51 | // Remove jobs upon completion |
| 52 | // (set this to `true` if you want jobs to removed from array upon completion) |
| 53 | // this will not remove jobs when `stop` is called |
| 54 | removeCompleted: false, |
| 55 | // Default timeout for jobs |
| 56 | // (set this to `false` if you do not wish for a default timeout to be set) |
| 57 | timeout: 0, |
| 58 | // Default interval for jobs |
| 59 | // (set this to `0` for no interval, and > 0 for a default interval to be set) |
| 60 | interval: 0, |
| 61 | // Default timezone for jobs |
| 62 | // Must be a IANA string (ie. 'America/New_York', 'EST', 'UTC', etc). |
| 63 | // To use the system specified timezone, set this to 'local' or 'system'. |
| 64 | timezone: 'local', |
| 65 | // This is an Array of your job definitions (see README for examples) |
| 66 | jobs: [], |
| 67 | // <https://breejs.github.io/later/parsers.html#cron> |
| 68 | // (can be overridden on a job basis with same prop name) |
| 69 | hasSeconds: false, |
| 70 | // <https://github.com/Airfooox/cron-validate> |
| 71 | cronValidate: {}, |
| 72 | // If you set a value > 0 here, then it will terminate workers after this time (ms) |
| 73 | closeWorkerAfterMs: 0, |
| 74 | // Could also be mjs if desired |
| 75 | // (this is the default extension if you just specify a job's name without ".js" or ".mjs") |
| 76 | defaultRootIndex: 'index.js', |
| 77 | defaultExtension: 'js', |
| 78 | // an array of accepted extensions |
| 79 | // NOTE: if you add to this array you must extend `createWorker` |
| 80 | // to deal with the conversion to acceptable files for |
| 81 | // Node Workers |
| 82 | acceptedExtensions: ['.js', '.mjs'], |
| 83 | // Default worker options to pass to ~`new Worker` |
| 84 | // (can be overridden on a per job basis) |
| 85 | // <https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options> |
| 86 | worker: {}, |
| 87 | // Custom handler to execute when error events are emitted by the workers or when they exit |
| 88 | // with non-zero code |
| 89 | // pass in a callback function with following signature: `(error, workerMetadata) => { // custom handling here }` |
| 90 | errorHandler: null, |
| 91 | // Custom handler executed when a `message` event is received from a worker. |
| 92 | // A special 'done' event is also broadcasted while leaving worker shutdown logic in place. |
| 93 | workerMessageHandler: null, |
| 94 | // |
| 95 | // if you set this to `true`, then a second arg is passed to log output |