mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
make daemon node kill/term/int selectable
This commit is contained in:
parent
31cee79545
commit
5b69ab66aa
@ -28,6 +28,14 @@
|
||||
<option value="number">try to convert reply to a number</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-closer"> on close</label>
|
||||
<select id="node-input-closer" style='width:70%'>
|
||||
<option value="SIGKILL">kill process immediately</option>
|
||||
<option value="SIGTERM">try to terminate process</option>
|
||||
<option value="SIGINT">try to interrupt process</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
@ -51,12 +59,13 @@
|
||||
category: 'advanced-function',
|
||||
color:"darksalmon",
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
command: {value:"",required:true},
|
||||
args: {value:""},
|
||||
cr: {value:false},
|
||||
redo: {value:true},
|
||||
op: {value:"string"},
|
||||
name: {value:""}
|
||||
closer: {value:"SIGKILL"}
|
||||
},
|
||||
inputs:1,
|
||||
outputs:3,
|
||||
|
@ -11,6 +11,7 @@ module.exports = function(RED) {
|
||||
this.op = n.op;
|
||||
this.redo = n.redo;
|
||||
this.running = false;
|
||||
this.closer = n.closer || "SIGKILL";
|
||||
var node = this;
|
||||
|
||||
function inputlistener(msg) {
|
||||
@ -110,10 +111,21 @@ module.exports = function(RED) {
|
||||
|
||||
node.on("close", function(done) {
|
||||
clearInterval(loop);
|
||||
if (node.child != null) { node.child.kill('SIGKILL'); }
|
||||
if (RED.settings.verbose) { node.log(node.cmd+" stopped"); }
|
||||
if (node.child != null) {
|
||||
var tout;
|
||||
node.child.on('exit', function() {
|
||||
if (tout) { clearTimeout(tout); }
|
||||
done();
|
||||
});
|
||||
tout = setTimeout(function() {
|
||||
node.child.kill("SIGKILL"); // if it takes more than 3 secs kill it anyway.
|
||||
done();
|
||||
}, 3000);
|
||||
node.child.kill(node.closer);
|
||||
if (RED.settings.verbose) { node.log(node.cmd+" stopped"); }
|
||||
}
|
||||
else { setTimeout(function() { done(); }, 100); }
|
||||
node.status({});
|
||||
setTimeout(function() { done(); }, 100);
|
||||
});
|
||||
|
||||
runit();
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-daemon",
|
||||
"version" : "0.0.20",
|
||||
"version" : "0.0.21",
|
||||
"description" : "A Node-RED node that runs and monitors a long running system command.",
|
||||
"dependencies" : {
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user