File 0038-Successfully-exit-of-salt-api-child-processes-when-S.patch of Package salt.4202
From f311b870de4b062a9b379274063b5dcbd7ba9f92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Wed, 14 Dec 2016 11:34:43 +0000
Subject: [PATCH 38/38] 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.
---
salt/netapi/rest_cherrypy/app.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/salt/netapi/rest_cherrypy/app.py b/salt/netapi/rest_cherrypy/app.py
index c260b5b..1ec071b 100644
--- a/salt/netapi/rest_cherrypy/app.py
+++ b/salt/netapi/rest_cherrypy/app.py
@@ -245,7 +245,9 @@ import itertools
import functools
import logging
import json
+import os
import StringIO
+import signal
import tarfile
import time
from multiprocessing import Process, Pipe
@@ -2033,6 +2035,12 @@ class WebsocketEndpoint(object):
listen=True)
stream = event.iter_events(full=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:
--
2.10.2