gevent模式
This commit is contained in:
parent
e0e749c62c
commit
bec0f0912f
|
|
@ -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()
|
||||
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
|
||||
|
||||
for proc in jobs:
|
||||
proc.join()
|
||||
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)
|
||||
|
||||
returnData = return_dict.values()
|
||||
for i in ntmp_list:
|
||||
plugins_info[i]['status'] = returnData[i]
|
||||
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):
|
||||
|
|
|
|||
5
cli.sh
5
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
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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'):
|
||||
|
|
|
|||
Loading…
Reference in New Issue