File: app.py

package info (click to toggle)
pg-auto-failover 2.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,368 kB
  • sloc: ansic: 58,369; python: 5,515; sql: 3,177; makefile: 629; sh: 35
file content (28 lines) | stat: -rwxr-xr-x 573 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env python3

#
# Write a Python application that knows how to exit gracefully when
# receiving SIGTERM (at docker compose down time), but doesn't know how to
# do much else.
#

import sys
import time
import signal
from datetime import datetime


def sigterm_handler(_signo, _stack_frame):
    sys.exit(0)


signal.signal(signal.SIGTERM, sigterm_handler)

if __name__ == "__main__":
    try:
        while True:
            print("%s" % datetime.now())
            time.sleep(600)
    except BaseException:
        # Keyboard Interrupt or something
        pass