Merge branch 'nginx' into 'master'
no health check See merge request mathwave/sprint!13
This commit is contained in:
commit
6915d337b5
@ -1,43 +0,0 @@
|
|||||||
from time import sleep
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
|
||||||
from django.db import connections, OperationalError
|
|
||||||
from requests import get
|
|
||||||
|
|
||||||
from daemons.management.commands.bot import bot
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
|
||||||
help = "starts health check"
|
|
||||||
|
|
||||||
def go(self):
|
|
||||||
db_conn = connections["default"]
|
|
||||||
try:
|
|
||||||
db_conn.cursor()
|
|
||||||
except OperationalError:
|
|
||||||
connected = False
|
|
||||||
else:
|
|
||||||
connected = True
|
|
||||||
if not connected:
|
|
||||||
bot.send_message(84367486, "База сдохла")
|
|
||||||
return
|
|
||||||
web_working = True
|
|
||||||
try:
|
|
||||||
code = get("http://web:80").status_code
|
|
||||||
if code != 200:
|
|
||||||
web_working = False
|
|
||||||
except:
|
|
||||||
web_working = False
|
|
||||||
if not web_working:
|
|
||||||
bot.send_message(84367486, "Сайт сдох")
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
get("http://storage:5555")
|
|
||||||
except:
|
|
||||||
bot.send_message(84367486, "Файловое хранилище сдохло")
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
|
||||||
sleep(60 * 5)
|
|
||||||
while True:
|
|
||||||
self.go()
|
|
||||||
sleep(60 * 30)
|
|
@ -125,24 +125,6 @@ services:
|
|||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
health_check:
|
|
||||||
image: mathwave/sprint-repo:sprint
|
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
command: ./manage.py health_check
|
|
||||||
environment:
|
|
||||||
SOLUTIONS_ROOT_EXTERNAL: "/sprint-data/data/solutions"
|
|
||||||
DB_PASSWORD: $DB_PASSWORD
|
|
||||||
DEBUG: $DEBUG
|
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
|
||||||
deploy:
|
|
||||||
mode: replicated
|
|
||||||
restart_policy:
|
|
||||||
condition: on-failure
|
|
||||||
update_config:
|
|
||||||
parallelism: 1
|
|
||||||
order: start-first
|
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
image: mathwave/sprint-repo:sprint
|
image: mathwave/sprint-repo:sprint
|
||||||
networks:
|
networks:
|
||||||
|
Loading…
Reference in New Issue
Block a user