Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
How do I create an IPC channel with a detached process in Node JS?

I am currently making a Minecraft server to be controlled with Node JS and child process. However, when trying to execute a minecraft command from node to be passed to the server, the server doesn't respond at all. After tinkering with it a bit I found that while the server is running properly, the server process is not connected with the parent node process. This is the code I am using:

//Spawn and run the server
var svEnv = cp.spawn("java", [
   "-Xms4096M",
   "-Xmx4096M",
   "-jar",
   "server.jar",
   "nogui"
], {
   shell: false,
   detached: true, 
   cwd: `${config.server.directoryPath}`,
   stdio: "pipe"
});
svEnv.unref();

To test executing a command I simply use svEnv.stdin.write(`${cmd}\n`). I've noticed what when detached is set to false, the commands execute fine, however when detached is enabled the server ignores the inputs, yet the callback function still executes when the write is done executing. I checked the connection properties of the server process:

svEnv.stdin.writable -> true

svEnv.connected -> false

I'm guessing that the detached option being set to true disconnects the IPC channels between the child and the parent.

Is it possible to have the IPC channels still be functional when the child process is detached?

note: I am using windows 10

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda