Commit 79fcb898 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 5caa1367
...@@ -8,7 +8,7 @@ const cron = require('node-cron'); ...@@ -8,7 +8,7 @@ const cron = require('node-cron');
let Hetzner = require('./Hetzner') let Hetzner = require('./Hetzner')
const cronRemover = require('node-cron'); const cronRemover = require('node-cron');
const cronRemover2 = require('node-cron'); const cronRemover2 = require('node-cron');
let _ = require('lodash')
const request = require('request'); const request = require('request');
const fs = require('fs') const fs = require('fs')
const cronSpeed = require('node-cron'); const cronSpeed = require('node-cron');
...@@ -72,27 +72,25 @@ cronRemover.schedule(' */1 * * * *', () => { ...@@ -72,27 +72,25 @@ cronRemover.schedule(' */1 * * * *', () => {
}); });
cronRemover2.schedule(' */1 * * * *', () => {
init2()
});
async function init() { async function init() {
await initToken() await initToken()
await addIp() await addIp()
await attacher() try {
await attacher()
}
} catch (e) {
async function init2() { }
await initToken()
await remover() await remover()
} }
async function checkIps(ip) { async function checkIps(ip) {
...@@ -191,6 +189,7 @@ async function attacher() { ...@@ -191,6 +189,7 @@ async function attacher() {
let serverId = await het.getMasterServerId() let serverId = await het.getMasterServerId()
serverId = parseInt(serverId) serverId = parseInt(serverId)
let ips = await het.getAllFloatingIps() let ips = await het.getAllFloatingIps()
ips=_.shuffle(ips)
let attached = false let attached = false
for (let i = 0; i < ips.length; i++) { for (let i = 0; i < ips.length; i++) {
if (typeof ips[i].server === "number") { if (typeof ips[i].server === "number") {
......
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