Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #-*- coding: utf-8 -*-
  2. import os, os.path
  3. import sys
  4. import shlex
  5. from lodel.context import LodelContext
  6. LodelContext.expose_modules(globals(), {
  7. 'lodel.plugin': ['LodelHook'],
  8. 'lodel.settings': ['Settings']})
  9. from lodel import buildconf #<-- This one is common to the build
  10. PLUGIN_PATH = os.path.dirname(__file__)
  11. ##@brief Return the root url of the instance
  12. #@warning no trailing slash
  13. def root_url():
  14. return Settings.sitename
  15. def static_url():
  16. return Settings.webui.static_url
  17. ##@brief uwsgi startup demo
  18. @LodelHook('lodel2_loader_main')
  19. def uwsgi_fork(hook_name, caller, payload):
  20. standalone = Settings.webui.standalone
  21. if standalone.lower() == 'false':
  22. return
  23. else:
  24. sockfile = os.path.join(buildconf.LODEL2VARDIR, 'uwsgi_sockets/')
  25. if not os.path.isdir(sockfile):
  26. os.mkdir(sockfile)
  27. sockfile = os.path.join(sockfile,
  28. Settings.sitename.replace('/','_') + '.sock')
  29. logfile = os.path.join(
  30. buildconf.LODEL2LOGDIR, 'uwsgi_%s.log' % (
  31. Settings.sitename.replace('/', '_')))
  32. if standalone.lower() == 'true':
  33. cmd='{uwsgi} --plugin python3 --http-socket {addr}:{port} --module \
  34. plugins.webui.run --socket {sockfile} --logto {logfile} -p {uwsgiworkers}'
  35. cmd = cmd.format(
  36. addr = Settings.webui.listen_address,
  37. port = Settings.webui.listen_port,
  38. uwsgi= Settings.webui.uwsgicmd,
  39. sockfile=sockfile,
  40. logfile = logfile,
  41. uwsgiworkers = Settings.webui.uwsgi_workers)
  42. if Settings.webui.virtualenv is not None:
  43. cmd += " --virtualenv %s" % Settings.webui.virtualenv
  44. elif Settings.webui.standalone == 'uwsgi':
  45. cmd = '{uwsgi} --plugin python3 --ini ./plugins/webui/uwsgi/uwsgi.ini \
  46. --socket {sockfile} --logto {logfile} -p {uwsgiworkers}'
  47. cmd = cmd.format(uwsgi = Settings.webui.uwsgicmd,
  48. sockfile = sockfile, logfile = logfile, uwsgiworkers=Settings.webui.uwsgi_workers)
  49. try:
  50. args = shlex.split(cmd)
  51. exit(os.execl(args[0], *args))
  52. except Exception as e:
  53. print("Webui plugin uwsgi execl fails cmd was '%s' error : " % cmd,
  54. e, file=sys.stderr)
  55. exit(1)