"""Crashing demo service: works for ~30 s, then dies with a traceback and exit code 1. With `restart: on-failure` Docker brings it back, so it also turns into 🔁 «цикл рестартов». Expected alerts: 💥 краш (exit 1), then 🔁 after 3 restarts within 10 minutes. """ import sys import time print("crash demo: starting, will fail in 30 s", flush=True) time.sleep(30) try: {}["db_url"] except KeyError: import traceback traceback.print_exc() print("ERROR fatal: config key db_url is missing", file=sys.stderr, flush=True) sys.exit(1)