📅  最后修改于: 2022-03-11 15:03:11.193000             🧑  作者: Mango
const cluster = require('cluster');
const db = new sqlite3.Database(':memory:')
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);
cluster.fork()
.on('exit', (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died`);
});
cluster.fork()
.on('exit', (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died`);
});
} else if (cluster.worker.id === 1){
db.run(QUERY1);
} else {
db.run(QUERY2);
}