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
 """
14
 """
15
 import imp
15
 import imp
16
 import importlib
16
 import importlib
17
+import os
17
 from urllib.parse import urlparse
18
 from urllib.parse import urlparse
18
 
19
 
19
 import tg
20
 import tg
110
         manager.run('mail_sender', MailSenderDaemon)
111
         manager.run('mail_sender', MailSenderDaemon)
111
 
112
 
112
 environment_loaded.register(lambda: start_daemons(daemons))
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
 # Note: here are fake translatable strings that allow to translate messages for reset password email content
116
 # Note: here are fake translatable strings that allow to translate messages for reset password email content
116
 duplicated_email_subject = l_('Password reset request')
117
 duplicated_email_subject = l_('Password reset request')

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

6
 
6
 
7
 
7
 
8
 class InterruptManager(object):
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
         self.daemons_manager = daemons_manager
18
         self.daemons_manager = daemons_manager
11
-        self.process_pid = os.getpid()
19
+        self.tracim_process_pid = tracim_process_pid
12
         self._install_sgnal_handlers()
20
         self._install_sgnal_handlers()
13
 
21
 
14
     def _install_sgnal_handlers(self) -> None:
22
     def _install_sgnal_handlers(self) -> None:
35
         self.daemons_manager.stop_all()
43
         self.daemons_manager.stop_all()
36
         # Web server is managed by end of stack like uwsgi, apache2.
44
         # Web server is managed by end of stack like uwsgi, apache2.
37
         # So to ask it's termination, we have to use standard kills signals
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)