Browse Source

Updated webui plugin to enable standalone mode

To start in standalone uwsgi set lodel2.webui.standalone=True in conf file and start loader.py
Yann Weber 8 years ago
parent
commit
5c8f46c51e

+ 4
- 0
install/conf.d/webui_plugin.ini View File

@@ -1,3 +1,7 @@
1
+[lodel2.webui]
2
+standalone=False
3
+#listen_address=127.0.0.1
4
+#listen_port=9090
1 5
 [lodel2.webui.sessions]
2 6
 directory=./sessions
3 7
 expiration=900

+ 7
- 1
install/loader.py View File

@@ -22,8 +22,14 @@ from lodel.settings.settings import Settings as settings
22 22
 settings('conf.d')
23 23
 from lodel.settings import Settings
24 24
 
25
+#Load plugins
26
+from lodel.plugin import Plugins
27
+Plugins.bootstrap()
25 28
 
26
-if __name__ == '__main__': # To allow running interactive python
29
+if __name__ == '__main__':
30
+    from lodel.plugin import LodelHook
31
+    LodelHook.call_hook('lodel2_loader_main', '__main__', None)
32
+    #Run interative python
27 33
     import code
28 34
     print("""
29 35
      Running interactive python in Lodel2 %s instance environment

+ 3
- 4
lodel/plugin/plugins.py View File

@@ -87,12 +87,11 @@ class Plugins(object):
87 87
         
88 88
     ##@brief Bootstrap the Plugins class
89 89
     @classmethod
90
-    def bootstrap(cls, plugins_directories):
90
+    def bootstrap(cls):
91 91
         from lodel.settings import Settings
92
-        cls.start(Settings.plugins_path)
92
+        for plugin_name in Settings.plugins:
93
+            cls.load_plugin(plugin_name)
93 94
     
94
-    ##@brief Start the Plugins class by explicitly giving a plugin directory path
95
-    # @param plugins_directories list : List of path
96 95
     @classmethod
97 96
     def start(cls, plugins_directories):
98 97
         import inspect

+ 0
- 1
lodel/settings/validator.py View File

@@ -173,7 +173,6 @@ def loglevel_val(value):
173 173
     return value.upper()
174 174
 
175 175
 def path_val(value):
176
-    print("DEBUG",os.getcwd())
177 176
     if not os.path.exists(value):
178 177
         raise SettingsValidationError(
179 178
                 "path '%s' doesn't exists" % value)

+ 8
- 0
plugins/webui/confspec.py View File

@@ -3,6 +3,14 @@
3 3
 from lodel.settings.validator import SettingValidator
4 4
 
5 5
 CONFSPEC = {
6
+    'lodel2.webui': {
7
+        'standalone': ( False,
8
+                        SettingValidator('bool')),
9
+        'listen_address': ( '127.0.0.1',
10
+                            SettingValidator('dummy')),
11
+        'listen_port': (    '9090',
12
+                            SettingValidator('int')),
13
+    },
6 14
     'lodel2.webui.sessions': {
7 15
         'directory': (  '/tmp/lodel2_session',
8 16
                         SettingValidator('path')),

+ 11
- 13
plugins/webui/main.py View File

@@ -1,17 +1,15 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
+import os
3 4
 from lodel.plugin import LodelHook
5
+from lodel.settings import Settings
4 6
 
5
-##@brief Hook's callback example
6
-@LodelHook('leapi_get_pre')
7
-@LodelHook('leapi_get_post')
8
-@LodelHook('leapi_update_pre')
9
-@LodelHook('leapi_update_post')
10
-@LodelHook('leapi_delete_pre')
11
-@LodelHook('leapi_delete_post')
12
-@LodelHook('leapi_insert_pre')
13
-@LodelHook('leapi_insert_post')
14
-def dummy_callback(hook_name, caller, payload):
15
-    if Lodel.settings.Settings.debug:
16
-        print("\tHook %s\tcaller %s with %s" % (hook_name, caller, payload))
17
-    return payload   
7
+##@brief uwsgi startup demo
8
+@LodelHook('lodel2_loader_main')
9
+def uwsgi_fork(hook_name, caller, payload):
10
+    if Settings.webui.standalone:
11
+        cmd='uwsgi_python3 --http-socket {addr}:{port} --module run'
12
+        cmd.format(
13
+                    addr = Settings.webui.listen_address,
14
+                    port = Settings.webui.listen_port)
15
+        exit(os.system(cmd))

Loading…
Cancel
Save