lookyloo/bin/stop.py

31 lines
737 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
from subprocess import Popen, run
2021-09-07 12:59:31 +02:00
from redis import Redis
2021-11-26 20:16:22 +01:00
from redis.exceptions import ConnectionError
2021-10-18 13:06:43 +02:00
from lookyloo.default import get_homedir, get_socket_path
2021-09-07 12:59:31 +02:00
def main():
get_homedir()
p = Popen(['shutdown'])
p.wait()
2021-11-26 20:16:22 +01:00
try:
r = Redis(unix_socket_path=get_socket_path('cache'), db=1)
r.delete('shutdown')
r = Redis(unix_socket_path=get_socket_path('cache'))
r.delete('tree_cache')
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()