File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,11 @@ from grpc_health.v1 import health_pb2_grpc
1313def main ():
1414
1515 commands = {
16- 'backup' : lambda stub , healthStub :
16+ 'backup' : lambda stub :
1717 stub .Backup (proto .BackupRequest ()),
18- 'restore' : lambda stub , healthStub :
18+ 'restore' : lambda stub :
1919 stub .RestoreFromBackup (proto .RestoreFromBackupRequest ()),
20- 'health' : lambda stub , healthStub :
21- healthStub .Check (health_pb2 .HealthCheckRequest (service = '' ))
20+ 'health' : None
2221 }
2322
2423 parser = argparse .ArgumentParser ()
@@ -47,11 +46,25 @@ def main():
4746 stub = proto_rpc .FossilDBStub (channel )
4847 healthStub = health_pb2_grpc .HealthStub (channel )
4948
50- reply = commands [args .command ](stub , healthStub )
49+ if args .command == 'health' :
50+ try :
51+ reply = healthStub .Check (health_pb2 .HealthCheckRequest (service = '' ))
52+ print (reply )
53+ UNKNOWN = 0 ;
54+ SERVING = 1 ;
55+ NOT_SERVING = 2 ;
56+ if reply .status != SERVING :
57+ raise Exception (reply .status )
58+ except Exception as e :
59+ print ('Health check unsuccessful. FossilDB offline?' )
60+ print (e )
61+ sys .exit (1 )
5162
52- print (reply )
53- if not reply .success :
54- sys .exit (1 )
63+ else :
64+ reply = commands [args .command ](stub )
65+ print (reply )
66+ if not reply .success :
67+ sys .exit (1 )
5568
5669
5770if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments