Spawn a child process in Electron

后端 未结 4 1017
野的像风
野的像风 2020-12-09 10:04

I\'m using Node v6.2.2 and Electron v1.2.5.

I have a small application that I\'ve built on top of Electron and now I need to fork the process to run som

4条回答
  •  囚心锁ツ
    2020-12-09 10:26

    Also, you can fork nodejs file inside electron process:

    let serverProc = require('child_process').fork(
      require.resolve('./server.js'),
      ['--key', 'value'], // pass to process.argv into child
      {
        // options
      }
    )
    serverProc.on('exit', (code, sig) => {
      // finishing
    })
    serverProc.on('error', (error) => {
      // error handling
    })
    

提交回复
热议问题