INNER CODE UNIT · TypeScript

workers

xiangsx/gpt4free-ts · index.ts:25

  const workers = +(process.env.WORKERS || 1);

  // Fork workers.
  for (let i = 0; i < workers; i++) {
    cluster.fork();
  }

  cluster.on('exit', (worker, code, signal) => {
    console.log(`worker ${worker.process.pid} died,sig: ${signal}`);
    console.log('Forking a new process...');
    cluster.fork(); // Fork a new process if a worker dies
  });
} else {
  require('./router').registerApp();
}
process.on('uncaughtException', (err) => {
  console.error('Uncaught exception:', err);
  setTimeout(() => process.exit(1), 5000); // It's up to you whether to exit here or not

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…