mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
20 lines
506 B
JavaScript
20 lines
506 B
JavaScript
|
const ScheduledTask = require('../scheduled-task');
|
||
|
|
||
|
let scheduledTask;
|
||
|
|
||
|
function register(message){
|
||
|
const script = require(message.path);
|
||
|
scheduledTask = new ScheduledTask(message.cron, script.task, message.options);
|
||
|
scheduledTask.on('task-done', (result) => {
|
||
|
process.send({ type: 'task-done', result});
|
||
|
});
|
||
|
process.send({ type: 'registred' });
|
||
|
}
|
||
|
|
||
|
process.on('message', (message) => {
|
||
|
switch(message.type){
|
||
|
case 'register':
|
||
|
return register(message);
|
||
|
}
|
||
|
});
|