2019-04-05 14:01:36 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2021-11-26 19:48:46 +01:00
|
|
|
from subprocess import Popen, run
|
2021-09-07 12:59:31 +02:00
|
|
|
|
2019-04-05 14:01:36 +02:00
|
|
|
from redis import Redis
|
2021-11-26 20:16:22 +01:00
|
|
|
from redis.exceptions import ConnectionError
|
2019-04-05 14:01:36 +02:00
|
|
|
|
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
|
|
|
|
2020-10-03 21:19:43 +02:00
|
|
|
|
2024-01-12 17:15:41 +01:00
|
|
|
def main() -> None:
|
2019-04-05 14:01:36 +02:00
|
|
|
get_homedir()
|
2020-10-03 21:19:43 +02:00
|
|
|
p = Popen(['shutdown'])
|
2019-04-05 14:01:36 +02:00
|
|
|
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
|
2020-10-03 21:19:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|