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>
|
<option value="number">try to convert reply to a number</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
@ -51,12 +59,13 @@
|
|||||||
category: 'advanced-function',
|
category: 'advanced-function',
|
||||||
color:"darksalmon",
|
color:"darksalmon",
|
||||||
defaults: {
|
defaults: {
|
||||||
|
name: {value:""},
|
||||||
command: {value:"",required:true},
|
command: {value:"",required:true},
|
||||||
args: {value:""},
|
args: {value:""},
|
||||||
cr: {value:false},
|
cr: {value:false},
|
||||||
redo: {value:true},
|
redo: {value:true},
|
||||||
op: {value:"string"},
|
op: {value:"string"},
|
||||||
name: {value:""}
|
closer: {value:"SIGKILL"}
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
outputs:3,
|
outputs:3,
|
||||||
|
@ -11,6 +11,7 @@ module.exports = function(RED) {
|
|||||||
this.op = n.op;
|
this.op = n.op;
|
||||||
this.redo = n.redo;
|
this.redo = n.redo;
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
this.closer = n.closer || "SIGKILL";
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
function inputlistener(msg) {
|
function inputlistener(msg) {
|
||||||
@ -110,10 +111,21 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
node.on("close", function(done) {
|
node.on("close", function(done) {
|
||||||
clearInterval(loop);
|
clearInterval(loop);
|
||||||
if (node.child != null) { node.child.kill('SIGKILL'); }
|
if (node.child != null) {
|
||||||
if (RED.settings.verbose) { node.log(node.cmd+" stopped"); }
|
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({});
|
node.status({});
|
||||||
setTimeout(function() { done(); }, 100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
runit();
|
runit();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-daemon",
|
"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.",
|
"description" : "A Node-RED node that runs and monitors a long running system command.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user