Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
How do you spawn a child process in an external folder?

I'm using Electron.js to build a browser application that hooks up to a flask back-end located in a separate folder in the directory. As of now, I'm using a hacky work-around to exec the back-end:

const bat = cp.exec("cd api && python app.py");

however I would ideally like to spawn a back-end child process in the API folder. How can I do that?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The child_process.exec() function has a specific option for the current working directory for the child process.

You can see it in the doc.

child_process.exec(command[, options][, callback])

    command <string> The command to run, with space-separated arguments.

    options <Object>
        cwd <string> | <URL> Current working directory of the child process. Default: process.cwd().
        ...

So, you can just set that option and specify the api directory:

const bat = cp.exec("python app.py", {
    cwd: path.join(process.cwd(), "api")
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda