Compare commits
No commits in common. "master" and "BiFaceAPI" have entirely different histories.
|
@ -75,44 +75,4 @@ exports.Reset = async function (req, res) {
|
||||||
res.send({status:true});
|
res.send({status:true});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Reboot = async function (req, res) {
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
execSync('sudo reboot now');
|
|
||||||
res.send({ status: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.ControlEngine = async function (req, res) {
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
if (req.body.action == "off")
|
|
||||||
execSync('sudo systemctl stop S905X_BI');
|
|
||||||
else
|
|
||||||
execSync('sudo systemctl start S905X_BI');
|
|
||||||
res.send({ status: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.EngineStatus = async function (req, res) {
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
try {
|
|
||||||
execSync('pgrep FaceProArm');
|
|
||||||
res.send({ status: true });
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
res.send({ status: false });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.SetupMedia = async function (req, res) {
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
var text = fs.readFileSync('/root/monitor/setup/engine.json', 'utf8');
|
|
||||||
var json = JSON.parse(text);
|
|
||||||
var folderEngine = json.data.engines[0].name;
|
|
||||||
try {
|
|
||||||
execSync('rm -rf /root/monitor/engine/' + folderEngine + '/data/audio');
|
|
||||||
execSync('ln -s /var/www/html/BiFace_Server_Lite/web/data/uploads /root/monitor/engine/' + folderEngine + '/data/bg/uploads');
|
|
||||||
execSync('ln -s /var/www/html/BiFace_Server_Lite/web/data/audio /root/monitor/engine/' + folderEngine + '/data/audio');
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
res.send({ status: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,4 @@ module.exports = function (app) {
|
||||||
|
|
||||||
app.route('/Reset').post(Api.Reset);
|
app.route('/Reset').post(Api.Reset);
|
||||||
|
|
||||||
app.route('/Reboot').post(Api.Reboot);
|
|
||||||
|
|
||||||
app.route('/ControlEngine').post(Api.ControlEngine);
|
|
||||||
|
|
||||||
app.route('/EngineStatus').get(Api.EngineStatus);
|
|
||||||
|
|
||||||
app.route('/SetupMedia').get(Api.SetupMedia);
|
|
||||||
};
|
};
|
||||||
|
|
31
server.js
31
server.js
|
@ -10,7 +10,6 @@ const http = require("http");
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
app.use(bodyParser.urlencoded({extended: true}));
|
app.use(bodyParser.urlencoded({extended: true}));
|
||||||
app.use(bodyParser.json({limit: '50mb'}));
|
app.use(bodyParser.json({limit: '50mb'}));
|
||||||
const { execSync } = require('child_process');
|
|
||||||
|
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
if (req.headers && req.headers.authorization && req.headers.authorization.split(' ')[0] === 'JWT') {
|
if (req.headers && req.headers.authorization && req.headers.authorization.split(' ')[0] === 'JWT') {
|
||||||
|
@ -64,7 +63,7 @@ setInterval(function () {
|
||||||
console.log("end");
|
console.log("end");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 20000);
|
}, 60000);
|
||||||
|
|
||||||
request.get({
|
request.get({
|
||||||
url: "http://localhost/api/re-gen-feature",
|
url: "http://localhost/api/re-gen-feature",
|
||||||
|
@ -98,34 +97,6 @@ setInterval(function () {
|
||||||
});
|
});
|
||||||
}, 120000);
|
}, 120000);
|
||||||
|
|
||||||
setInterval(function () {
|
|
||||||
request.get({
|
|
||||||
url: "http://localhost/api/check-time-engine",
|
|
||||||
json: true,
|
|
||||||
headers: { 'User-Agent': 'request' }
|
|
||||||
}, (err, res, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.log('Error:', err);
|
|
||||||
} else if (res.statusCode !== 200) {
|
|
||||||
console.log('Status:', res.statusCode);
|
|
||||||
} else {
|
|
||||||
// data is already parsed as JSON:
|
|
||||||
console.log("check-time-engine", data.status);
|
|
||||||
var processActive = false;
|
|
||||||
try {
|
|
||||||
execSync('pgrep FaceProArm');
|
|
||||||
processActive = true;
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
if (processActive && !data.status)
|
|
||||||
execSync('sudo systemctl stop S905X_BI');
|
|
||||||
if (!processActive && data.status)
|
|
||||||
execSync('sudo systemctl start S905X_BI');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
console.log('BiFace Started On Port: ' + port);
|
console.log('BiFace Started On Port: ' + port);
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user