diff --git a/bin/stop.py b/bin/stop.py index a156c80..0e5c561 100755 --- a/bin/stop.py +++ b/bin/stop.py @@ -4,6 +4,7 @@ from subprocess import Popen, run from redis import Redis +from redis.exceptions import ConnectionError from lookyloo.default import get_homedir, get_socket_path @@ -12,14 +13,18 @@ def main(): get_homedir() p = Popen(['shutdown']) p.wait() - 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 = run(['run_backend', '--stop']) - p.check_returncode() - print('done.') + 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__':