B
B
Bekkazy2017-08-25 15:23:53
Node.js
Bekkazy, 2017-08-25 15:23:53

How to see if child process is running?

I have code:

function checkStunnel(){
    // return true
    return false
}
function stunnelConnection(){
    if(!checkStunnel()){
        execFile('./stunnel/bin/stunnel.exe', (error, stdout, stderr) => {
            if (error) {
                // throw error;
                throw new Error( error );
            }
            console.log('error',error);
            console.log('stdout',stdout);
            console.log('stderr',stderr);
        });
    }
}

In the function, you need to implement a check to see if stunnel is already running and if it is not running, return false.
How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rustler2000, 2017-08-26
@rustler2000

On *nix usually via the .pid file, or via the service status in systemd\upstart\... .
That is, you should not directly call the process - but do something like '''systemctl service stunnel start''' '''/etc/init.d/stunnel start''' .... that is, run through the "wrapper"
And, accordingly, through "wrapper" and find out the status is running\working\dead

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question