]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pakfire/patches/0009-daemon-Restart-keepalive-daemon-after-it-has-crashed.patch
pakfire: Sync with upstream.
[people/ms/ipfire-3.x.git] / pakfire / patches / 0009-daemon-Restart-keepalive-daemon-after-it-has-crashed.patch
1 From 11ec9629f460bbd6169e8f934d0194912ff257e0 Mon Sep 17 00:00:00 2001
2 From: Michael Tremer <michael.tremer@ipfire.org>
3 Date: Sat, 30 Mar 2013 12:21:29 +0000
4 Subject: [PATCH 09/19] daemon: Restart keepalive daemon after it has crashed.
5
6 ---
7 python/pakfire/daemon.py | 27 +++++++++++++++++++++++++++
8 1 file changed, 27 insertions(+)
9
10 diff --git a/python/pakfire/daemon.py b/python/pakfire/daemon.py
11 index 8c453e0..267b330 100644
12 --- a/python/pakfire/daemon.py
13 +++ b/python/pakfire/daemon.py
14 @@ -73,6 +73,10 @@ class PakfireDaemon(object):
15 while self.__running:
16 time_started = time.time()
17
18 + # Check if keepalive process is still alive.
19 + if not self.keepalive.is_alive():
20 + self.restart_keepalive(wait=10)
21 +
22 # Spawn a sufficient number of worker processes.
23 self.spawn_workers_if_needed()
24
25 @@ -96,6 +100,29 @@ class PakfireDaemon(object):
26 log.info(_("Shutting down..."))
27 self.__running = False
28
29 + def restart_keepalive(self, wait=None):
30 + log.critial(_("Restarting keepalive process"))
31 +
32 + # Send SIGTERM to really end the process.
33 + self.keepalive.terminate()
34 +
35 + # Wait for the process to terminate.
36 + if wait:
37 + self.keepalive.join(wait)
38 +
39 + # Remove the keepalive process from the process list.
40 + try:
41 + self.__workers.remove(self.keepalive)
42 + except ValueError:
43 + pass
44 +
45 + # Create a new process and start it.
46 + self.keepalive = PakfireDaemonKeepalive(self.config)
47 + self.keepalive.start()
48 +
49 + # Add the process to the process list.
50 + self.__workers.append(self.keepalive)
51 +
52 def spawn_workers_if_needed(self, *args, **kwargs):
53 """
54 Spawns more workers if needed.
55 --
56 1.8.1.4
57