Добавить варианты изображений, очистку staging, replay и сценарии отказа
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Windows hooks for the public resilience client."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def docker(*args):
|
||||
return subprocess.check_output(['docker', *args], cwd=ROOT, text=True).strip()
|
||||
|
||||
|
||||
def main():
|
||||
if sys.argv[1] == 'restart':
|
||||
docker('compose', 'restart', '-t', '4', 'db', 'redis', 's3', 'broker', 'api',
|
||||
'dispatcher', 'worker', 'staging-cleaner', 'lb')
|
||||
return
|
||||
target = os.environ['TARGET_INSTANCE_ID']
|
||||
for container in docker('compose', 'ps', '-q', 'api').splitlines():
|
||||
name = docker('inspect', '--format', '{{.Config.Hostname}}', container)
|
||||
prefix, _, suffix = target.rpartition('-')
|
||||
if prefix == name and len(suffix) == 8:
|
||||
docker('stop', '-t', '2', container)
|
||||
return
|
||||
raise SystemExit('API instance not found')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user