3 4from unit.applications.proto import TestApplicationProto 5 6 7class TestApplicationPython(TestApplicationProto): 8 application_type = "python" 9 10 def load(self, script, name=None, **kwargs): 11 if name is None: 12 name = script 13 14 if script[0] == '/': 15 script_path = script 16 else: 17 script_path = self.current_dir + '/python/' + script 18 19 if kwargs.get('isolation') and kwargs['isolation'].get('rootfs'): 20 rootfs = kwargs['isolation']['rootfs'] 21 22 if not os.path.exists(rootfs + '/app/python/'): 23 os.makedirs(rootfs + '/app/python/') 24 25 if not os.path.exists(rootfs + '/app/python/' + name): 26 shutil.copytree(script_path, rootfs + '/app/python/' + name) 27 28 script_path = '/app/python/' + name 29 30 self._load_conf( 31 { 32 "listeners": {"*:7080": {"pass": "applications/" + name}}, 33 "applications": { 34 name: { 35 "type": self.application_type, 36 "processes": {"spare": 0}, 37 "path": script_path, 38 "working_directory": script_path, 39 "module": "wsgi", 40 } 41 }, 42 }, 43 **kwargs 44 )
| 3 4from unit.applications.proto import TestApplicationProto 5 6 7class TestApplicationPython(TestApplicationProto): 8 application_type = "python" 9 10 def load(self, script, name=None, **kwargs): 11 if name is None: 12 name = script 13 14 if script[0] == '/': 15 script_path = script 16 else: 17 script_path = self.current_dir + '/python/' + script 18 19 if kwargs.get('isolation') and kwargs['isolation'].get('rootfs'): 20 rootfs = kwargs['isolation']['rootfs'] 21 22 if not os.path.exists(rootfs + '/app/python/'): 23 os.makedirs(rootfs + '/app/python/') 24 25 if not os.path.exists(rootfs + '/app/python/' + name): 26 shutil.copytree(script_path, rootfs + '/app/python/' + name) 27 28 script_path = '/app/python/' + name 29 30 self._load_conf( 31 { 32 "listeners": {"*:7080": {"pass": "applications/" + name}}, 33 "applications": { 34 name: { 35 "type": self.application_type, 36 "processes": {"spare": 0}, 37 "path": script_path, 38 "working_directory": script_path, 39 "module": "wsgi", 40 } 41 }, 42 }, 43 **kwargs 44 )
|