Browse Source

InterruptManager: give tracil pid at creation

Bastien Sevajol 8 years ago
parent
commit
0143590387
2 changed files with 13 additions and 4 deletions
  1. 2 1
      tracim/tracim/config/app_cfg.py
  2. 11 3
      tracim/tracim/lib/system.py

+ 2 - 1
tracim/tracim/config/app_cfg.py View File

@@ -14,6 +14,7 @@ convert them into boolean, for example, you should use the
14 14
 """
15 15
 import imp
16 16
 import importlib
17
+import os
17 18
 from urllib.parse import urlparse
18 19
 
19 20
 import tg
@@ -110,7 +111,7 @@ def start_daemons(manager: DaemonsManager):
110 111
         manager.run('mail_sender', MailSenderDaemon)
111 112
 
112 113
 environment_loaded.register(lambda: start_daemons(daemons))
113
-interrupt_manager = InterruptManager(daemons_manager=daemons)
114
+interrupt_manager = InterruptManager(os.getpid(), daemons_manager=daemons)
114 115
 
115 116
 # Note: here are fake translatable strings that allow to translate messages for reset password email content
116 117
 duplicated_email_subject = l_('Password reset request')

+ 11 - 3
tracim/tracim/lib/system.py View File

@@ -6,9 +6,17 @@ from tracim.lib.daemons import DaemonsManager
6 6
 
7 7
 
8 8
 class InterruptManager(object):
9
-    def __init__(self, daemons_manager: DaemonsManager):
9
+    def __init__(
10
+            self,
11
+            tracim_process_pid: int,
12
+            daemons_manager: DaemonsManager,
13
+    ) -> None:
14
+        """
15
+        :param tracim_process_pid: pid of tracim.
16
+        :param daemons_manager: Tracim daemons manager
17
+        """
10 18
         self.daemons_manager = daemons_manager
11
-        self.process_pid = os.getpid()
19
+        self.tracim_process_pid = tracim_process_pid
12 20
         self._install_sgnal_handlers()
13 21
 
14 22
     def _install_sgnal_handlers(self) -> None:
@@ -35,4 +43,4 @@ class InterruptManager(object):
35 43
         self.daemons_manager.stop_all()
36 44
         # Web server is managed by end of stack like uwsgi, apache2.
37 45
         # So to ask it's termination, we have to use standard kills signals
38
-        os.kill(self.process_pid, signum)
46
+        os.kill(self.tracim_process_pid, signum)