How to automatically restart a process using Node in NW.JS?
阿神
阿神 2017-05-16 13:39:20
0
2
537

My project is developed based on NW.JS. When a certain condition is met, I need to restart the client, but I really don’t know enough about NODE. I need help from experts to solve it. Thank you! !
Whether it is the nw.js method or the node method, as long as the program can be restarted~

阿神
阿神

闭关修行中......

reply all(2)
我想大声告诉你
var nwRestart = function () {
    var child, child_process = require('child_process');
    if (process.platform == "darwin") {
        child = child_process.spawn("open", ["-n", "-a", process.execPath.match(/^([^rrreee]+?\.app)\//)[1]], { detached: true });
    } else {
        child = child_process.spawn(process.execPath, [], { detached: true });
    }
    child.unref();
    require("nw.gui").Window.get().hide();
    process._nw_app.quit();
};
nwRestart();

This is suitable for older nw clients. If the nw version you are using is relatively new, you need to modify it accordingly, mainly to get nw_app to exit at the end

迷茫

@QiCheen Thank you so much~Thank you!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template