mirror of
https://github.com/yweber/lodel2.git
synced 2026-06-28 04:10:48 +02:00
Updated webui plugin to enable standalone mode
To start in standalone uwsgi set lodel2.webui.standalone=True in conf file and start loader.py
This commit is contained in:
parent
8b702a4cc1
commit
5c8f46c51e
6 changed files with 33 additions and 19 deletions
|
|
@ -1,3 +1,7 @@
|
|||
[lodel2.webui]
|
||||
standalone=False
|
||||
#listen_address=127.0.0.1
|
||||
#listen_port=9090
|
||||
[lodel2.webui.sessions]
|
||||
directory=./sessions
|
||||
expiration=900
|
||||
|
|
|
|||
|
|
@ -22,8 +22,14 @@ from lodel.settings.settings import Settings as settings
|
|||
settings('conf.d')
|
||||
from lodel.settings import Settings
|
||||
|
||||
#Load plugins
|
||||
from lodel.plugin import Plugins
|
||||
Plugins.bootstrap()
|
||||
|
||||
if __name__ == '__main__': # To allow running interactive python
|
||||
if __name__ == '__main__':
|
||||
from lodel.plugin import LodelHook
|
||||
LodelHook.call_hook('lodel2_loader_main', '__main__', None)
|
||||
#Run interative python
|
||||
import code
|
||||
print("""
|
||||
Running interactive python in Lodel2 %s instance environment
|
||||
|
|
|
|||
|
|
@ -87,12 +87,11 @@ class Plugins(object):
|
|||
|
||||
##@brief Bootstrap the Plugins class
|
||||
@classmethod
|
||||
def bootstrap(cls, plugins_directories):
|
||||
def bootstrap(cls):
|
||||
from lodel.settings import Settings
|
||||
cls.start(Settings.plugins_path)
|
||||
for plugin_name in Settings.plugins:
|
||||
cls.load_plugin(plugin_name)
|
||||
|
||||
##@brief Start the Plugins class by explicitly giving a plugin directory path
|
||||
# @param plugins_directories list : List of path
|
||||
@classmethod
|
||||
def start(cls, plugins_directories):
|
||||
import inspect
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ def loglevel_val(value):
|
|||
return value.upper()
|
||||
|
||||
def path_val(value):
|
||||
print("DEBUG",os.getcwd())
|
||||
if not os.path.exists(value):
|
||||
raise SettingsValidationError(
|
||||
"path '%s' doesn't exists" % value)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,14 @@
|
|||
from lodel.settings.validator import SettingValidator
|
||||
|
||||
CONFSPEC = {
|
||||
'lodel2.webui': {
|
||||
'standalone': ( False,
|
||||
SettingValidator('bool')),
|
||||
'listen_address': ( '127.0.0.1',
|
||||
SettingValidator('dummy')),
|
||||
'listen_port': ( '9090',
|
||||
SettingValidator('int')),
|
||||
},
|
||||
'lodel2.webui.sessions': {
|
||||
'directory': ( '/tmp/lodel2_session',
|
||||
SettingValidator('path')),
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from lodel.plugin import LodelHook
|
||||
from lodel.settings import Settings
|
||||
|
||||
##@brief Hook's callback example
|
||||
@LodelHook('leapi_get_pre')
|
||||
@LodelHook('leapi_get_post')
|
||||
@LodelHook('leapi_update_pre')
|
||||
@LodelHook('leapi_update_post')
|
||||
@LodelHook('leapi_delete_pre')
|
||||
@LodelHook('leapi_delete_post')
|
||||
@LodelHook('leapi_insert_pre')
|
||||
@LodelHook('leapi_insert_post')
|
||||
def dummy_callback(hook_name, caller, payload):
|
||||
if Lodel.settings.Settings.debug:
|
||||
print("\tHook %s\tcaller %s with %s" % (hook_name, caller, payload))
|
||||
return payload
|
||||
##@brief uwsgi startup demo
|
||||
@LodelHook('lodel2_loader_main')
|
||||
def uwsgi_fork(hook_name, caller, payload):
|
||||
if Settings.webui.standalone:
|
||||
cmd='uwsgi_python3 --http-socket {addr}:{port} --module run'
|
||||
cmd.format(
|
||||
addr = Settings.webui.listen_address,
|
||||
port = Settings.webui.listen_port)
|
||||
exit(os.system(cmd))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue