2020-07-01 20:01:47 +05:30
|
|
|
import argparse
|
|
|
|
|
2020-03-14 22:47:35 +05:30
|
|
|
from check_connection import (
|
|
|
|
check_redis_cache,
|
|
|
|
check_redis_queue,
|
|
|
|
check_redis_socketio,
|
2021-12-10 11:53:00 +03:00
|
|
|
check_service,
|
2020-03-14 22:47:35 +05:30
|
|
|
)
|
2020-02-10 13:30:54 +05:30
|
|
|
|
2020-04-29 01:45:59 +05:30
|
|
|
|
2020-07-01 20:01:47 +05:30
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
2021-12-10 11:52:40 +03:00
|
|
|
"-p",
|
|
|
|
"--ping-service",
|
|
|
|
dest="ping_services",
|
|
|
|
action="append",
|
2020-07-01 20:01:47 +05:30
|
|
|
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 22:47:35 +05:30
|
|
|
def main():
|
2020-07-01 20:01:47 +05:30
|
|
|
args = parse_args()
|
|
|
|
check_service(retry=1, delay=0, print_attempt=False)
|
|
|
|
print("Bench database Connected")
|
2020-03-14 22:47:35 +05:30
|
|
|
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 13:40:23 +05:30
|
|
|
|
2021-12-10 11:52:40 +03:00
|
|
|
if args.ping_services:
|
2020-07-01 20:01:47 +05:30
|
|
|
for service in args.ping_services:
|
2020-07-02 13:40:23 +05:30
|
|
|
service_name = None
|
|
|
|
service_port = None
|
|
|
|
|
|
|
|
try:
|
2021-12-10 11:52:40 +03:00
|
|
|
service_name, service_port = service.split(":")
|
2020-07-02 13:40:23 +05:30
|
|
|
except ValueError:
|
2021-12-10 11:52:40 +03:00
|
|
|
print("Service should be in format host:port, e.g postgres:5432")
|
2020-07-02 13:40:23 +05:30
|
|
|
exit(1)
|
|
|
|
|
2020-07-01 20:01:47 +05:30
|
|
|
check_service(
|
|
|
|
retry=1,
|
|
|
|
delay=0,
|
|
|
|
print_attempt=False,
|
|
|
|
service_name=service_name,
|
|
|
|
service_port=service_port,
|
|
|
|
)
|
2021-12-10 11:51:47 +03:00
|
|
|
print(f"{service_name}:{service_port} Connected")
|
2020-03-14 22:47:35 +05:30
|
|
|
|
|
|
|
print("Health check successful")
|
|
|
|
exit(0)
|
|
|
|
|
2020-04-29 01:45:59 +05:30
|
|
|
|
2020-03-14 22:47:35 +05:30
|
|
|
if __name__ == "__main__":
|
2020-03-20 20:56:23 +05:30
|
|
|
main()
|