diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index 2a2c71327..0484e13f5 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -70,7 +70,6 @@ class plugins_api: def indexListApi(self): data = self.getIndexList() - # print data return public.getJson(data) def indexSortApi(self): @@ -251,23 +250,33 @@ class plugins_api: else: return_dict[i] = False - def checkStatusThreads(self, plugins_info): - manager = multiprocessing.Manager() - return_dict = manager.dict() - jobs = [] - ntmp_list = range(len(plugins_info)) - for i in ntmp_list: - p = multiprocessing.Process( - target=self.checkStatusProcess, args=(plugins_info[i], i, return_dict)) - jobs.append(p) - p.start() - - for proc in jobs: - proc.join() + def checkStatusThreads(self, info, i): + if not info['setup']: + return False + data = self.run(info['name'], 'status', info['setup_version']) + if data[0] == 'start': + return True + else: + return False - returnData = return_dict.values() - for i in ntmp_list: - plugins_info[i]['status'] = returnData[i] + def checkStatusMThreads(self, plugins_info): + try: + threads = [] + ntmp_list = range(len(plugins_info)) + for i in ntmp_list: + t = pa_thread(self.checkStatusThreads, (plugins_info[i], i)) + threads.append(t) + + for i in ntmp_list: + threads[i].start() + for i in ntmp_list: + threads[i].join() + + for i in ntmp_list: + t = threads[i].getResult() + plugins_info[i]['status'] = t + except Exception as e: + print 'checkStatusMThreads:', str(e) return plugins_info @@ -453,7 +462,7 @@ class plugins_api: end = start + pageSize _plugins_info = plugins_info[start:end] - # _plugins_info = self.checkStatusMProcess(_plugins_info) + _plugins_info = self.checkStatusMThreads(_plugins_info) return (_plugins_info, len(plugins_info)) def makeListThread(self, data, sType='0'): @@ -601,7 +610,6 @@ class plugins_api: public.writeFile(self.__index, '[]') indexList = json.loads(public.readFile(self.__index)) - print self.__index, indexList plist = [] app = [] for i in indexList: @@ -623,7 +631,9 @@ class plugins_api: except Exception, e: print 'getIndexList:', e + # 使用gevent模式时,无法使用多进程 # plist = self.checkStatusMProcess(plist) + plist = self.checkStatusMThreads(plist) return plist def setIndexSort(self, sort): diff --git a/cli.sh b/cli.sh index f4ffd210a..0632ce220 100755 --- a/cli.sh +++ b/cli.sh @@ -1,5 +1,5 @@ #!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/lib/python2.7/bin @@ -13,7 +13,8 @@ mw_start_debug(){ # gunicorn -c setting.py app:app python task.py & # gunicorn -b :7200 app:app - gunicorn -b :7200 -k gevent app:app + gunicorn -b :7200 -k gevent -w 1 app:app + # gunicorn -b :7200 -k eventlet -w 1 app:app # gunicorn -c setting.py app:app } diff --git a/plugins/webssh/js/webssh.js b/plugins/webssh/js/webssh.js index 7cd01e883..e1cabfff2 100755 --- a/plugins/webssh/js/webssh.js +++ b/plugins/webssh/js/webssh.js @@ -1,12 +1,15 @@ function web_shell2() { - var termCols = 50; - var termRows = 12; + var termCols = 65; + var termRows = 18; var sendTotal = 0; if(!socket)socket = io.connect(); var term = new Terminal({ cols: termCols, rows: termRows, screenKeys: true, useStyle: true}); + console.log(term); + // term.fit() term.open(); gterm = term term.setOption('cursorBlink', true); + term.setOption('fontSize', 10); socket.on('server_response', function (data) { console.log('server_response',data); diff --git a/route/__init__.py b/route/__init__.py index ded2fd5d1..e85fc3717 100755 --- a/route/__init__.py +++ b/route/__init__.py @@ -100,7 +100,7 @@ def publicObject(toObject, func, action=None, get=None): return data except Exception as e: data = {'msg': '访问异常:' + str(e) + '!', "status": False} - return public.getInfo(data) + return public.getJson(data) @app.route("/test") diff --git a/setting.py b/setting.py index 1703539b6..b7a5fc530 100755 --- a/setting.py +++ b/setting.py @@ -10,9 +10,9 @@ sys.path.append("/usr/local/lib/python2.7/site-packages") import public import system_api -# cpu_info = system_api.system_api().getCpuInfo() -# workers = cpu_info[1] + 1 -workers = 1 +cpu_info = system_api.system_api().getCpuInfo() +workers = cpu_info[1] + 1 +# workers = 2 if not os.path.exists(os.getcwd() + '/logs'):