Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
cómo implementar multiprocesamiento en serverless-offline con node js, express, cluster,

Estoy tratando de usar un clúster sin servidor sin conexión. pero después de ejecutar serverless offline , me da el siguiente error

 offline: Failure: offline: handler 'handler' in /home/Documents/cluster is not a function Error: offline: handler 'handler' in /home/Documents/cluster is not a function at InProcessRunner.run (/home/Documents/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:160:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async LambdaFunction.runHandler (/home/Documents/node_modules/serverless-offline/dist/lambda/LambdaFunction.js:368:20) at async hapiHandler (/home/Documents/node_modules/serverless-offline/dist/events/http/HttpServer.js:702:18) at async exports.Manager.execute (/home/Documents/node_modules/@hapi/hapi/lib/toolkit.js:60:28) at async Object.internals.handler (/home/Documents/node_modules/@hapi/hapi/lib/handler.js:46:20) at async exports.execute (/home/Documents/node_modules/@hapi/hapi/lib/handler.js:31:20) at async Request._lifecycle (/home/Documents/node_modules/@hapi/hapi/lib/request.js:371:32) at async Request._execute (/home/Documents/node_modules/@hapi/hapi/lib/request.js:281:9)

y después de eso comienza a matar el proceso. No tengo idea de cómo implementar un clúster sin servidor sin conexión.

si llamo al controlador sin servidor en el proceso maestro, funciona el archivo para un solo hilo pero no para el proceso secundario.

 const cluster = require("cluster"); const totalCPUs = require("os").cpus().length; const serverless = require("serverless-http"); const app = require("./api"); console.log("cluster.isMaster", cluster.isMaster); if (cluster.isMaster) { console.log(`Number of CPUs is ${totalCPUs}`); console.log(`Master ${process.pid} is running`); // Fork workers. for (let i = 0; i < totalCPUs; i++) { cluster.fork(); } module.exports.handler = serverless(app);// if I declare here it works fine cluster.on("exit", (worker, code, signal) => { // console.log(`process killed:`, worker.kill()); console.log(`${worker.process.pid} is killed`); // console.log("code, signal ", code, signal); // cluster.fork(); console.log(`new proccess pid: ${process.pid}`); }); } else { console.log("process pid ", process.pid); // console.log("serverless(app)",app); // runServer.runServer(); module.exports.handler = serverless(app);// if I declare here never get called and //kill all process }

por favor guía, estoy frustrado de implementar esto porque lo estoy haciendo desde hace mucho tiempo pero no obtengo ninguna solución.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!