Search code examples
javascriptnode.jsconsole-applicationbackground-process

Node.JS | Is it possible to move self to background?


Yes, I know this question exists, but unfortunately it doesn't answer this specific question.

I am writing a Node.JS app to control multiple Steam trade bots and I am adding a terminal like interface to it. This will allow me to start and stop bots whenever. However is it possible to move the program into the background with just Node.JS code?

I would like to have a command like this:

function processCmd(cmd){
    var cmdArgs = cmd.split(" ");
    switch(cmdArgs[0]){
        case "bg":
            console.log("Moving to background...");
            // move program to background
            break;
    }
}

Is this possible? Or do I just have to restart the program manually?


Solution

  • The easiest way I found to keep it running was just use the forever package and allow access via an HTTP server port. Nevertheless thanks for your suggestions!