mirror of
https://github.com/yweber/lodel2.git
synced 2026-10-30 08:11:33 +01: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]
|
[lodel2.webui.sessions]
|
||||||
directory=./sessions
|
directory=./sessions
|
||||||
expiration=900
|
expiration=900
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,14 @@ from lodel.settings.settings import Settings as settings
|
||||||
settings('conf.d')
|
settings('conf.d')
|
||||||
from lodel.settings import Settings
|
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
|
import code
|
||||||
print("""
|
print("""
|
||||||
Running interactive python in Lodel2 %s instance environment
|
Running interactive python in Lodel2 %s instance environment
|
||||||
|
|
|
||||||
|
|
@ -87,12 +87,11 @@ class Plugins(object):
|
||||||
|
|
||||||
##@brief Bootstrap the Plugins class
|
##@brief Bootstrap the Plugins class
|
||||||
@classmethod
|
@classmethod
|
||||||
def bootstrap(cls, plugins_directories):
|
def bootstrap(cls):
|
||||||
from lodel.settings import Settings
|
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
|
@classmethod
|
||||||
def start(cls, plugins_directories):
|
def start(cls, plugins_directories):
|
||||||
import inspect
|
import inspect
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,6 @@ def loglevel_val(value):
|
||||||
return value.upper()
|
return value.upper()
|
||||||
|
|
||||||
def path_val(value):
|
def path_val(value):
|
||||||
print("DEBUG",os.getcwd())
|
|
||||||
if not os.path.exists(value):
|
if not os.path.exists(value):
|
||||||
raise SettingsValidationError(
|
raise SettingsValidationError(
|
||||||
"path '%s' doesn't exists" % value)
|
"path '%s' doesn't exists" % value)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,14 @@
|
||||||
from lodel.settings.validator import SettingValidator
|
from lodel.settings.validator import SettingValidator
|
||||||
|
|
||||||
CONFSPEC = {
|
CONFSPEC = {
|
||||||
|
'lodel2.webui': {
|
||||||
|
'standalone': ( False,
|
||||||
|
SettingValidator('bool')),
|
||||||
|
'listen_address': ( '127.0.0.1',
|
||||||
|
SettingValidator('dummy')),
|
||||||
|
'listen_port': ( '9090',
|
||||||
|
SettingValidator('int')),
|
||||||
|
},
|
||||||
'lodel2.webui.sessions': {
|
'lodel2.webui.sessions': {
|
||||||
'directory': ( '/tmp/lodel2_session',
|
'directory': ( '/tmp/lodel2_session',
|
||||||
SettingValidator('path')),
|
SettingValidator('path')),
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,15 @@
|
||||||
#-*- coding: utf-8 -*-
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
from lodel.plugin import LodelHook
|
from lodel.plugin import LodelHook
|
||||||
|
from lodel.settings import Settings
|
||||||
|
|
||||||
##@brief Hook's callback example
|
##@brief uwsgi startup demo
|
||||||
@LodelHook('leapi_get_pre')
|
@LodelHook('lodel2_loader_main')
|
||||||
@LodelHook('leapi_get_post')
|
def uwsgi_fork(hook_name, caller, payload):
|
||||||
@LodelHook('leapi_update_pre')
|
if Settings.webui.standalone:
|
||||||
@LodelHook('leapi_update_post')
|
cmd='uwsgi_python3 --http-socket {addr}:{port} --module run'
|
||||||
@LodelHook('leapi_delete_pre')
|
cmd.format(
|
||||||
@LodelHook('leapi_delete_post')
|
addr = Settings.webui.listen_address,
|
||||||
@LodelHook('leapi_insert_pre')
|
port = Settings.webui.listen_port)
|
||||||
@LodelHook('leapi_insert_post')
|
exit(os.system(cmd))
|
||||||
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
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue