Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rt2old
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
rt2old
Commits
9bebf2df
Commit
9bebf2df
authored
Nov 14, 2020
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
63199ca0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
app.js
app.js
+21
-4
No files found.
app.js
View file @
9bebf2df
...
@@ -8,7 +8,7 @@ const cronSpeed = require('node-cron');
...
@@ -8,7 +8,7 @@ const cronSpeed = require('node-cron');
const
shellExec
=
require
(
'
shell-exec
'
)
const
shellExec
=
require
(
'
shell-exec
'
)
var
decimalPointRegex
=
/
\-?\d
+
\.\d
+/g
;
var
decimalPointRegex
=
/
\-?\d
+
\.\d
+/g
;
let
port
=
5
let
port
=
5
let
countReboot
=
4
let
countReboot
=
4
...
@@ -58,13 +58,17 @@ app.listen(3000, () => console.log(`Example app listening on port 3000!`))
...
@@ -58,13 +58,17 @@ app.listen(3000, () => console.log(`Example app listening on port 3000!`))
async
function
run
()
{
async
function
run
()
{
port
=
randomInt
(
4000
,
60000
)
let
portRes
=
await
getPort
()
let
a
=
await
shell
.
exec
(
'
cd .. && cd mt && sudo ./server1.sh
'
+
port
,
{
silent
:
true
}).
stdout
;
if
(
portRes
===
'
0
'
||
portRes
===
'
443
'
)
port
=
randomInt
(
4000
,
60000
)
else
port
=
parseInt
(
portRes
)
let
a
=
await
shell
.
exec
(
'
cd .. && cd mt && sudo ./server1.sh
'
+
port
,
{
silent
:
true
}).
stdout
;
console
.
log
(
'
Reset Proxy
'
)
console
.
log
(
'
Reset Proxy
'
)
}
}
async
function
checkProcessWork
()
{
async
function
checkProcessWork
()
{
let
a
=
await
shell
.
exec
(
'
nc -vz 127.0.0.1
'
+
port
).
stderr
;
let
a
=
await
shell
.
exec
(
'
nc -vz 127.0.0.1
'
+
port
).
stderr
;
if
(
a
.
includes
(
'
succeeded
'
))
{
if
(
a
.
includes
(
'
succeeded
'
))
{
tryFail
=
0
tryFail
=
0
return
true
return
true
...
@@ -131,6 +135,19 @@ function sendRate(rx, tx) {
...
@@ -131,6 +135,19 @@ function sendRate(rx, tx) {
}
}
function
getPort
()
{
const
request
=
require
(
'
request
'
);
let
url
=
'
http://admin.fcfglobal.co:3000/getPort
'
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
(
url
,
{
timeout
:
15000
},
function
(
error
,
res
,
body
)
{
resolve
(
body
)
});
});
}
cronSpeed
.
schedule
(
'
*/5 * * * * *
'
,
()
=>
{
cronSpeed
.
schedule
(
'
*/5 * * * * *
'
,
()
=>
{
return
calculateSpeed
()
return
calculateSpeed
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment