Answers for "sqlite3 multithreading nodejs"

1

sqlite3 multithreading nodejs

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);
}
Posted by: Guest on April-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language