How to use the scheduler.onWorker function in scheduler

To help you get started, weโ€™ve selected a few scheduler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kyriosli / agentk / src / service / daemon.js View on Github external
lastRespawn = now;
                fastRespawn = 0;
            }
            console.log(`${formatTime(now)} daemon.js::respawn: program[${dir}] worker[${i}]`);
            restarted[i]++;
            program.lastRestart = Date.now();
            let worker = workers[i] = _spawn(process.execPath, args, option);
            worker.program = program;
            worker.on('exit', onExit);
            worker.on('message', onMessage);
            if (timeStamp) {
                worker.stdout.pid = worker.stderr.pid = worker.pid;
                worker.stdout.on('data', onPipeData1);
                worker.stderr.on('data', onPipeData2);
            }
            scheduler.onWorker(worker);
        }
    }