Commit dc64bcdc authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 0ebccc81
......@@ -17,7 +17,6 @@ class Hetzner {
client.servers.list().then(function (res) {
// console.log(res)
let d = _.values(res.servers);
console.log(d)
resolve(d)
})
......@@ -38,10 +37,16 @@ class Hetzner {
async removeByIp(ip) {
try {
ip=_.trim(ip)
console.log('try to remove ip:'+ip)
let servers = await this.getAllServers()
for (let i = 0; i < servers.length; i++) {
if (ip === servers[i].publicNet.server.publicNet.ipv4.ip)
{
await this.deleteServer(servers[i].id)
}
}
} catch (e) {
......
......@@ -55,7 +55,7 @@ cron.schedule('*/10 * * * * *', () => {
checkProcessWork()
});
remover()
cronRemover.schedule(' */1 * * * *', () => {
remover()
......@@ -68,8 +68,8 @@ async function remover() {
if (work === 'true')
return true
let ip = getIp()
console.log(ip)
var contents = await fs.readFileSync('./token.txt', 'utf8');
console.log(contents)
let Hetzner = require('./Hetzner')
let het = new Hetzner(contents)
await het.removeByIp(ip)
......
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