Refactored shinobi-tensorflow.js (by moe and thellamafarm)
parent
18b3ae1c45
commit
db13c16260
|
@ -24,17 +24,23 @@ try{
|
|||
return console.log(config.plug, 'Plugin start has failed. pluginBase.js was not found.')
|
||||
}
|
||||
}
|
||||
// Base Init />>
|
||||
var spawn = require('child_process').spawn;
|
||||
var child = spawn('python3', ['-u', 'detect_image.py']);
|
||||
|
||||
|
||||
var ready = false;
|
||||
const spawn = require('child_process').spawn;
|
||||
var child = null
|
||||
function respawn() {
|
||||
|
||||
console.log("respawned python",(new Date()))
|
||||
const theChild = spawn('python3', ['-u', 'detect_image.py']);
|
||||
|
||||
var lastStatusLog = new Date();
|
||||
|
||||
child.on('close', function() {
|
||||
child = spawn('python3', ['-u', 'detect_image.py']);
|
||||
theChild.on('exit', () => {
|
||||
child = respawn();
|
||||
});
|
||||
|
||||
child.stdout.on('data', function (data) {
|
||||
theChild.stdout.on('data', function (data) {
|
||||
var rawString = data.toString('utf8');
|
||||
if (new Date() - lastStatusLog > 5000) {
|
||||
lastStatusLog = new Date();
|
||||
|
@ -59,6 +65,14 @@ child.stdout.on('data', function (data) {
|
|||
}
|
||||
})
|
||||
})
|
||||
return theChild
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Base Init />>
|
||||
child = respawn();
|
||||
|
||||
const emptyDataObject = { data: [], type: undefined, time: 0 };
|
||||
|
||||
|
|
Loading…
Reference in New Issue