BGP-Ranking/bin/stop.py

30 lines
671 B
Python
Raw Normal View History

2018-07-13 14:51:00 +02:00
#!/usr/bin/env python3
2018-03-29 22:37:28 +02:00
# -*- coding: utf-8 -*-
2021-12-06 14:30:08 +01:00
from subprocess import Popen, run
2018-03-29 22:37:28 +02:00
2021-12-06 14:30:08 +01:00
from redis import Redis
from redis.exceptions import ConnectionError
from bgpranking.default import get_homedir, get_socket_path
def main():
2018-03-30 14:33:33 +02:00
get_homedir()
2021-12-06 14:30:08 +01:00
p = Popen(['shutdown'])
2018-03-29 22:37:28 +02:00
p.wait()
2021-12-06 14:30:08 +01:00
try:
r = Redis(unix_socket_path=get_socket_path('cache'), db=1)
r.delete('shutdown')
print('Shutting down databases...')
p_backend = run(['run_backend', '--stop'])
p_backend.check_returncode()
print('done.')
except ConnectionError:
# Already down, skip the stacktrace
pass
if __name__ == '__main__':
main()