Commit 36ba3611 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 8facffc5
const express = require('express')
const app = express()
const port = 3000
const shell=require('shelljs')
const shell = require('shelljs')
const cron = require('node-cron');
startup()
app.get('/', (req, res) =>
{
app.get('/', (req, res) => {
res.send('Hello World!')
run()
})
......@@ -14,14 +13,17 @@ app.get('/', (req, res) =>
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
async function startup()
{
let a = await shell.exec('cd .. && cd mt && sudo ./server1.sh', {silent: true}).stdout;
console.log('Run Proxy at Start up')
}
async function run() {
let a = await shell.exec('cd .. && cd mt && sudo ./kill.sh && sudo ./server1.sh', {silent: true}).stdout;
let a = await shell.exec('cd .. && cd mt && sudo ./server1.sh', {silent: true}).stdout;
console.log('Reset Proxy')
}
async function checkProcessWork() {
let a = await shell.exec('nc -vz 127.0.0.1 443', {silent: true}).stdout;
return a.includes('succeeded')
}
cron.schedule('*/10 * * * * *', () => {
checkProcessWork()
});
......@@ -7,6 +7,7 @@
},
"dependencies": {
"express": "~4.16.0",
"shelljs": "^0.8.3"
"shelljs": "^0.8.3",
"node-cron": "^2.0.3"
}
}
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