Commit 7307d109 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 2967a739
......@@ -10,6 +10,9 @@ const shellExec = require('shell-exec')
var decimalPointRegex = /\-?\d+\.\d+/g;
let countReboot = 5
let tryFail = 0
app.get('/', (req, res) => {
res.send('Hello World!')
run()
......@@ -60,8 +63,18 @@ async function run() {
async function checkProcessWork() {
let a = await shell.exec('nc -vz 127.0.0.1 443').stderr;
if (a.includes('succeeded'))
if (a.includes('succeeded')) {
tryFail = 0
return true
}
tryFail++
if (tryFail >= countReboot)
{
reboot()
return
}
run()
}
......@@ -71,8 +84,6 @@ cron.schedule('*/10 * * * * *', () => {
});
async function calculateSpeed() {
......@@ -82,7 +93,6 @@ async function calculateSpeed() {
let arr = d.match(decimalPointRegex)
if (d.includes('kbit/s')) {
arr[0] = 1
arr[1] = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment