Add sigterm handler to shutdown from rc.d scripts

This commit is contained in:
Michael Chen 2014-10-23 01:06:38 -07:00 committed by evilhero
parent 78e8110015
commit 395ca8b75c
1 changed files with 6 additions and 1 deletions

View File

@ -17,6 +17,7 @@
import os, sys, locale
import time
import threading
import signal
from lib.configobj import ConfigObj
@ -28,7 +29,9 @@ try:
import argparse
except ImportError:
import lib.argparse as argparse
def handler_sigterm(signum, frame):
mylar.SIGNAL = 'shutdown'
def main():
@ -173,6 +176,8 @@ def main():
# Start the background threads
mylar.start()
signal.signal(signal.SIGTERM, handler_sigterm)
while True:
if not mylar.SIGNAL: