mirror of
https://github.com/lalanza808/monero.fail.git
synced 2025-08-19 15:37:47 -04:00
Automatically remove dead nodes (#18)
* remove nodes if all the health checks are failed * use utc * node should have at least 5 health checks
This commit is contained in:
parent
b0df1f66c4
commit
c78fe4f9f1
2 changed files with 14 additions and 1 deletions
|
@ -157,7 +157,7 @@ def add():
|
|||
return redirect("/")
|
||||
|
||||
def cleanup_health_checks():
|
||||
diff = datetime.now() - timedelta(hours=24)
|
||||
diff = datetime.utcnow() - timedelta(hours=24)
|
||||
checks = HealthCheck.select().where(HealthCheck.datetime <= diff)
|
||||
for check in checks:
|
||||
print("Deleting check", check.id)
|
||||
|
@ -201,6 +201,11 @@ def check():
|
|||
node.datetime_checked = now
|
||||
node.save()
|
||||
hc.save()
|
||||
if node.get_failed_checks().count() == node.get_all_checks().count() and node.get_all_checks().count() > 5:
|
||||
print('this node fails all of its health checks - deleting it!')
|
||||
for _hc in node.get_all_checks():
|
||||
_hc.delete_instance()
|
||||
node.delete_instance()
|
||||
|
||||
@app.cli.command("get_peers")
|
||||
def get_peers():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue