Browse Source

Bugfix in webui uswgi socket file creation

Now create an INSTANCE_NAME.sock in @localstatedir@/uwsgi_sockets
Note : the localstatedir is wrong -_- /usr/var instead of /var........
Yann Weber 8 years ago
parent
commit
704582bc16

+ 14
- 4
plugins/webui/main.py View File

@@ -5,6 +5,7 @@ import sys
5 5
 import shlex
6 6
 from lodel.plugin import LodelHook
7 7
 from lodel.settings import Settings
8
+from lodel import buildconf
8 9
 
9 10
 PLUGIN_PATH = os.path.dirname(__file__)
10 11
 
@@ -22,18 +23,27 @@ def uwsgi_fork(hook_name, caller, payload):
22 23
     if standalone.lower() == 'false':
23 24
         return
24 25
     else:
26
+        sockfile = os.path.join(buildconf.LODEL2VARDIR, 'uwsgi_sockets/')
27
+        if not os.path.isdir(sockfile):
28
+            os.mkdir(sockfile)
29
+        sockfile = os.path.join(sockfile,
30
+            Settings.sitename.replace('/','_') + '.sock')
25 31
         if standalone.lower() == 'true':
26
-            cmd='{uwsgi} --http-socket {addr}:{port} --module plugins.webui.run'
32
+            cmd='{uwsgi} --http-socket {addr}:{port} --module \
33
+plugins.webui.run --socket {sockfile}'
27 34
             cmd = cmd.format(
28 35
                         addr = Settings.webui.listen_address,
29 36
                         port = Settings.webui.listen_port,
30
-                        uwsgi= Settings.webui.uwsgicmd)
37
+                        uwsgi= Settings.webui.uwsgicmd,
38
+                        sockfile=sockfile)
31 39
             if Settings.webui.virtualenv is not None:
32 40
                 cmd += " --virtualenv %s" % Settings.webui.virtualenv
33 41
 
34 42
         elif Settings.webui.standalone == 'uwsgi':
35
-            cmd = '{uwsgi} --ini ./plugins/webui/uwsgi/uwsgi.ini'
36
-            cmd = cmd.format(uwsgi = Settings.webui.uwsgicmd)
43
+            cmd = '{uwsgi} --ini ./plugins/webui/uwsgi/uwsgi.ini \
44
+--socket {sockfile}'
45
+            cmd = cmd.format(uwsgi = Settings.webui.uwsgicmd, 
46
+                sockfile = sockfile)
37 47
         
38 48
         try:
39 49
             args = shlex.split(cmd)

+ 0
- 1
plugins/webui/uwsgi/uwsgi.ini View File

@@ -2,7 +2,6 @@
2 2
 model = run:application
3 3
 plugin = python3
4 4
 module = plugins.webui.run
5
-socket = lodel2.sock
6 5
 chmod-socket = 666
7 6
 vacuum = true
8 7
 die-on-term = true #enable sigterm for killing

+ 1
- 1
progs/slim/install_model/conf.d/lodel2.ini View File

@@ -21,7 +21,7 @@ dummy =
21 21
 dummy =
22 22
 
23 23
 [lodel2.logging.stderr]
24
-level = DEBUG
24
+level = INFO
25 25
 filename = -
26 26
 context = True
27 27
 

+ 8
- 2
progs/slim/slim.py View File

@@ -86,7 +86,7 @@ def set_conf(name, args):
86 86
     if interface == 'webui':
87 87
         if 'lodel2.webui' not in config:
88 88
             config['lodel2.webui'] = dict()
89
-            config['lodel2.webui']['standalone'] = 'True'
89
+            config['lodel2.webui']['standalone'] = 'uwsgi'
90 90
         if args.listen_port is not None:
91 91
             config['lodel2.webui']['listen_port'] = str(args.listen_port)
92 92
         if args.listen_address is not None:
@@ -151,7 +151,7 @@ it" % name)
151 151
     logging.warning("Deleting instance %s" % name)
152 152
     logging.info("Deleting instance folder %s" % store_datas[name]['path'])
153 153
     shutil.rmtree(store_datas[name]['path'])
154
-    logging.info("Deleting instance from json store file")
154
+    logging.debug("Deleting instance from json store file")
155 155
     del(store_datas[name])
156 156
     save_datas(store_datas)
157 157
 
@@ -322,6 +322,10 @@ def details_instance(name, verbosity, batch):
322 322
         print(msg)
323 323
     else:
324 324
         msg = name
325
+        if name in pids and is_running(name, pids[name]):
326
+            msg += ' %d ' % pids[name]
327
+        else:
328
+            msg += ' stopped '
325 329
         if verbosity > 0:
326 330
             msg += "\t"+'"%s"' % store_datas[name]['path']
327 331
         if verbosity > 1:
@@ -418,10 +422,12 @@ if __name__ == '__main__':
418 422
         for name in args.name:
419 423
             new_instance(name)
420 424
     elif args.purge:
425
+        # SLIM Purge (stop & delete all)
421 426
         print("Do you really want to delete all the instances ? Yes/no ",)
422 427
         rep = sys.stdin.readline()
423 428
         if rep == "Yes\n":
424 429
             store = get_store_datas()
430
+            stop_instances(store.keys())
425 431
             for name in store:
426 432
                 delete_instance(name)
427 433
         elif rep.lower() != 'no':

Loading…
Cancel
Save