Home  >  Q&A  >  body text

javascript - How to open another process after closing the main process in node?

Although this requirement seems a bit illogical, what I need to achieve is an automatic update effect. ZIP downloaded from the server, compressed to another folder, and then close the old version before opening the new version.
Because it is based on NW.JS, it does not support multi-window preview, so before starting a new process (Nw window), you must first close the old process (nw window). Since NW 0.1.3, multiple windows at the same time are not supported. It's on, so. . Quite embarrassing. .
But I think it can definitely meet my needs. After all, there is a NW-AUTOUPDATER that has also been implemented, but it does not meet the project requirements and cannot be used, so I am asking all the experts for advice. Thank you!

習慣沉默習慣沉默2686 days ago547

reply all(1)I'll reply

  • 某草草

    某草草2017-05-16 13:47:05

    It seems to be similar to the implementation in my framework...
    https://github.com/llwslc/ele...

    First download the zip package in the background, click upgrade to call the following code

        exec(`start update.exe ${pkgInfo.name} ${process.pid}`, {encoding: 'binary'});
        app.exit(0);

    Pass the current path path and program pid to update.exe, and then the program exits...
    update.exe will monitor the pid until the pid disappears...
    After the pid disappears, update.exe will decompress the zip package...
    After decompression is completed, restart the main program and exit by yourself...

    Just unzip directly under mac, no need to start a new program...

    reply
    0
  • Cancelreply