2020-07-01 14:31:47 +00:00
|
|
|
import argparse
|
|
|
|
|
2020-03-14 17:17:35 +00:00
|
|
|
from check_connection import (
|
2020-07-01 14:31:47 +00:00
|
|
|
check_service,
|
2020-03-14 17:17:35 +00:00
|
|
|
check_redis_cache,
|
|
|
|
check_redis_queue,
|
|
|
|
check_redis_socketio,
|
|
|
|
)
|
2020-02-10 08:00:54 +00:00
|
|
|
|
2020-04-28 20:15:59 +00:00
|
|
|
|
2020-07-01 14:31:47 +00:00
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
|
|
|
'-p',
|
|
|
|
'--ping-service',
|
|
|
|
dest='ping_services',
|
|
|
|
action='append',
|
|
|
|
type=str,
|
|
|
|
help='list of services to ping, e.g. doctor -p "postgres:5432" --ping-service "mariadb:3306"',
|
|
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
return args
|
|
|
|
|
|
|
|
|
2020-03-14 17:17:35 +00:00
|
|
|
def main():
|
2020-07-01 14:31:47 +00:00
|
|
|
args = parse_args()
|
|
|
|
check_service(retry=1, delay=0, print_attempt=False)
|
|
|
|
print("Bench database Connected")
|
2020-03-14 17:17:35 +00:00
|
|
|
check_redis_cache(retry=1, delay=0, print_attempt=False)
|
|
|
|
print("Redis Cache Connected")
|
|
|
|
check_redis_queue(retry=1, delay=0, print_attempt=False)
|
|
|
|
print("Redis Queue Connected")
|
|
|
|
check_redis_socketio(retry=1, delay=0, print_attempt=False)
|
|
|
|
print("Redis SocketIO Connected")
|
2020-07-02 08:10:23 +00:00
|
|
|
|
2020-07-01 14:31:47 +00:00
|
|
|
if(args.ping_services):
|
|
|
|
for service in args.ping_services:
|
2020-07-02 08:10:23 +00:00
|
|
|
service_name = None
|
|
|
|
service_port = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
service_name, service_port = service.split(':')
|
|
|
|
except ValueError:
|
|
|
|
print('Service should be in format host:port, e.g postgres:5432')
|
|
|
|
exit(1)
|
|
|
|
|
2020-07-01 14:31:47 +00:00
|
|
|
check_service(
|
|
|
|
retry=1,
|
|
|
|
delay=0,
|
|
|
|
print_attempt=False,
|
|
|
|
service_name=service_name,
|
|
|
|
service_port=service_port,
|
|
|
|
)
|
2021-12-10 08:51:47 +00:00
|
|
|
print(f"{service_name}:{service_port} Connected")
|
2020-03-14 17:17:35 +00:00
|
|
|
|
|
|
|
print("Health check successful")
|
|
|
|
exit(0)
|
|
|
|
|
2020-04-28 20:15:59 +00:00
|
|
|
|
2020-03-14 17:17:35 +00:00
|
|
|
if __name__ == "__main__":
|
2020-03-20 15:26:23 +00:00
|
|
|
main()
|