mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Successfully exit of salt-api child processes when SIGTERM.
So far, salt-api handles connection creating child processes, but this new processes are not handling the SIGTERM signal, so when `systemctl stop salt-api` is called the salt-api service is going to be KILLED by `TimeoutStopSec=3` option of salt-api service. This causes that salt-api looks as FAILED for systemd even if we perform a manually stop. FAILED systemd services has different behavior when `systemd try-restart` is called so we may have troubles i.e. when updating salt-api package. This commit enables SIGTERM handling for salt-api child processes to perform a successfully exit after SIGTERM.
This commit is contained in:
parent
70f7d22ad6
commit
ee6eae9855
1 changed files with 8 additions and 0 deletions
|
@ -424,7 +424,9 @@ import itertools
|
|||
import functools
|
||||
import logging
|
||||
import json
|
||||
import os
|
||||
import StringIO
|
||||
import signal
|
||||
import tarfile
|
||||
import time
|
||||
from multiprocessing import Process, Pipe
|
||||
|
@ -2182,6 +2184,12 @@ class WebsocketEndpoint(object):
|
|||
listen=True)
|
||||
stream = event.iter_events(full=True, auto_reconnect=True)
|
||||
SaltInfo = event_processor.SaltInfo(handler)
|
||||
|
||||
def signal_handler(signal, frame):
|
||||
os._exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
while True:
|
||||
data = next(stream)
|
||||
if data:
|
||||
|
|
Loading…
Add table
Reference in a new issue