Browse Source

Start daemon at environment_loaded step

Bastien Sevajol (Algoo) 8 years ago
parent
commit
ced4d4f6be

+ 14 - 0
tracim/tracim/config/app_cfg.py View File

@@ -15,6 +15,7 @@ convert them into boolean, for example, you should use the
15 15
 
16 16
 import tg
17 17
 from paste.deploy.converters import asbool
18
+from tg.configuration.milestones import environment_loaded
18 19
 
19 20
 from tgext.pluggable import plug
20 21
 from tgext.pluggable import replace_template
@@ -27,6 +28,8 @@ from tracim.config import TracimAppConfig
27 28
 from tracim.lib import app_globals, helpers
28 29
 from tracim.lib.auth.wrapper import AuthConfigWrapper
29 30
 from tracim.lib.base import logger
31
+from tracim.lib.daemons import DaemonsManager
32
+from tracim.lib.daemons import RadicaleDaemon
30 33
 from tracim.model.data import ActionDescription
31 34
 from tracim.model.data import ContentType
32 35
 
@@ -83,6 +86,17 @@ plug(base_config, 'resetpassword', 'reset_password')
83 86
 replace_template(base_config, 'resetpassword.templates.index', 'tracim.templates.reset_password_index')
84 87
 replace_template(base_config, 'resetpassword.templates.change_password', 'mako:tracim.templates.reset_password_change_password')
85 88
 
89
+daemons = DaemonsManager()
90
+
91
+
92
+def start_daemons(manager: DaemonsManager):
93
+    """
94
+    Sart Tracim daemons
95
+    """
96
+    manager.run('radicale', RadicaleDaemon)
97
+
98
+environment_loaded.register(lambda: start_daemons(daemons))
99
+
86 100
 # Note: here are fake translatable strings that allow to translate messages for reset password email content
87 101
 duplicated_email_subject = l_('Password reset request')
88 102
 duplicated_email_body = l_('''

+ 0 - 2
tracim/tracim/config/middleware.py View File

@@ -36,7 +36,5 @@ def make_app(global_conf, full_stack=True, **app_conf):
36 36
     app = make_base_app(global_conf, full_stack=True, **app_conf)
37 37
     
38 38
     # Wrap your base TurboGears 2 application with custom middleware here
39
-    daemons = DaemonsManager(app)
40
-    daemons.run('radicale', RadicaleDaemon)
41 39
 
42 40
     return app

+ 1 - 2
tracim/tracim/lib/daemons.py View File

@@ -16,8 +16,7 @@ from tracim.lib.utils import add_signal_handler
16 16
 
17 17
 
18 18
 class DaemonsManager(object):
19
-    def __init__(self, app: TGApp):
20
-        self._app = app
19
+    def __init__(self):
21 20
         self._running_daemons = {}
22 21
         add_signal_handler(signal.SIGTERM, self.stop_all)
23 22
         add_signal_handler(signal.SIGINT, self.stop_all)