From 4c0b64a6f81b678824c35a16db9ba04462e36d32 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 16 Feb 2014 01:38:26 +0100 Subject: signal handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/__main__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/__main__.py b/src/__main__.py index 881b3c1..03d99b8 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -15,7 +15,9 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . import os +import sys import time +import signal import datetime from colour import * @@ -147,6 +149,16 @@ if periodically is not None: wd = t.isocalendar()[2] periodically(t.year, t.month, t.day, t.hour, t.minute, t.second, wd, fade) + ## Catch TERM signal + def signal_SIGTERM(signum, frame): + if not running: + running = False + start_over() + monitor_controller() + sys.exit(0) + running = False + signal.signal(signal.SIGTERM, signal_SIGTERM) + ## Fade in early_exit = False ftime = 0 -- cgit v1.2.3-70-g09d2