mirror of
https://github.com/evilhero/mylar
synced 2025-01-12 09:51:36 +00:00
Add sigterm handler to shutdown from rc.d scripts
This commit is contained in:
parent
78e8110015
commit
395ca8b75c
1 changed files with 6 additions and 1 deletions
7
Mylar.py
7
Mylar.py
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue