This commit is contained in:
parent
3104e512fa
commit
e0e749c62c
|
|
@ -70,11 +70,8 @@ class plugins_api:
|
|||
|
||||
def indexListApi(self):
|
||||
data = self.getIndexList()
|
||||
print data
|
||||
# return public.getJson(data)
|
||||
print public.returnJson(True, '成功!')
|
||||
return public.returnJson(True, '成功!')
|
||||
# return rr
|
||||
# print data
|
||||
return public.getJson(data)
|
||||
|
||||
def indexSortApi(self):
|
||||
sort = request.form.get('ssort', '')
|
||||
|
|
@ -244,7 +241,6 @@ class plugins_api:
|
|||
return False
|
||||
|
||||
def checkStatusProcess(self, info, i, return_dict):
|
||||
|
||||
if not info['setup']:
|
||||
return_dict[i] = False
|
||||
return
|
||||
|
|
@ -255,7 +251,7 @@ class plugins_api:
|
|||
else:
|
||||
return_dict[i] = False
|
||||
|
||||
def checkStatusMProcess(self, plugins_info):
|
||||
def checkStatusThreads(self, plugins_info):
|
||||
manager = multiprocessing.Manager()
|
||||
return_dict = manager.dict()
|
||||
jobs = []
|
||||
|
|
@ -275,6 +271,25 @@ class plugins_api:
|
|||
|
||||
return plugins_info
|
||||
|
||||
def checkStatusMProcess(self, plugins_info):
|
||||
manager = multiprocessing.Manager()
|
||||
return_dict = manager.dict()
|
||||
jobs = []
|
||||
for i in range(len(plugins_info)):
|
||||
p = multiprocessing.Process(
|
||||
target=self.checkStatusProcess, args=(plugins_info[i], i, return_dict))
|
||||
jobs.append(p)
|
||||
p.start()
|
||||
|
||||
for proc in jobs:
|
||||
proc.join()
|
||||
|
||||
returnData = return_dict.values()
|
||||
for i in ntmp_list:
|
||||
plugins_info[i]['status'] = returnData[i]
|
||||
|
||||
return plugins_info
|
||||
|
||||
def checkDisplayIndex(self, name, version):
|
||||
if not os.path.exists(self.__index):
|
||||
public.writeFile(self.__index, '[]')
|
||||
|
|
@ -359,6 +374,7 @@ class plugins_api:
|
|||
pluginInfo['setup_version'] = self.getVersion(
|
||||
pluginInfo['install_checks'])
|
||||
# pluginInfo['status'] = self.checkStatus(pluginInfo)
|
||||
pluginInfo['status'] = False
|
||||
return pluginInfo
|
||||
|
||||
def makeCoexist(self, data):
|
||||
|
|
@ -437,7 +453,7 @@ class plugins_api:
|
|||
end = start + pageSize
|
||||
_plugins_info = plugins_info[start:end]
|
||||
|
||||
_plugins_info = self.checkStatusMProcess(_plugins_info)
|
||||
# _plugins_info = self.checkStatusMProcess(_plugins_info)
|
||||
return (_plugins_info, len(plugins_info))
|
||||
|
||||
def makeListThread(self, data, sType='0'):
|
||||
|
|
@ -585,7 +601,7 @@ class plugins_api:
|
|||
public.writeFile(self.__index, '[]')
|
||||
|
||||
indexList = json.loads(public.readFile(self.__index))
|
||||
|
||||
print self.__index, indexList
|
||||
plist = []
|
||||
app = []
|
||||
for i in indexList:
|
||||
|
|
@ -605,9 +621,9 @@ class plugins_api:
|
|||
plist.append(tmp_data[index])
|
||||
continue
|
||||
except Exception, e:
|
||||
print e
|
||||
print 'getIndexList:', e
|
||||
|
||||
plist = self.checkStatusMProcess(plist)
|
||||
# plist = self.checkStatusMProcess(plist)
|
||||
return plist
|
||||
|
||||
def setIndexSort(self, sort):
|
||||
|
|
|
|||
|
|
@ -202,6 +202,9 @@ def returnData(status, msg, data=None):
|
|||
|
||||
|
||||
def returnJson(status, msg, data=None):
|
||||
# if data == None:
|
||||
# return {'status': status, 'msg': msg}
|
||||
# return {'status': status, 'msg': msg, 'data': data}
|
||||
if data == None:
|
||||
return getJson({'status': status, 'msg': msg})
|
||||
return getJson({'status': status, 'msg': msg, 'data': data})
|
||||
|
|
|
|||
6
cli.sh
6
cli.sh
|
|
@ -4,7 +4,7 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
|||
|
||||
|
||||
mw_start(){
|
||||
gunicorn -c setting.py app:app &
|
||||
gunicorn -c setting.py app:app
|
||||
python task.py &
|
||||
}
|
||||
|
||||
|
|
@ -12,8 +12,8 @@ mw_start(){
|
|||
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 app:app
|
||||
gunicorn -b :7200 -k gevent app:app
|
||||
# gunicorn -c setting.py app:app
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import shutil
|
|||
import uuid
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
sys.setdefaultencoding('utf-8')
|
||||
|
||||
|
||||
from datetime import timedelta
|
||||
|
|
@ -26,6 +26,7 @@ from flask_session import Session
|
|||
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
import db
|
||||
import public
|
||||
import config_api
|
||||
|
|
@ -35,13 +36,8 @@ app.config.version = config_api.config_api().getVersion()
|
|||
# app.config['SECRET_KEY'] = os.urandom(24)
|
||||
# app.secret_key = uuid.UUID(int=uuid.getnode()).hex[-12:]
|
||||
app.config['SECRET_KEY'] = uuid.UUID(int=uuid.getnode()).hex[-12:]
|
||||
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
|
||||
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31)
|
||||
|
||||
# socketio
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
from flask_socketio import SocketIO, emit, send
|
||||
socketio = SocketIO()
|
||||
socketio.init_app(app)
|
||||
|
||||
try:
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
|
@ -64,6 +60,11 @@ app.config['SESSION_KEY_PREFIX'] = 'MW_:'
|
|||
app.config['SESSION_COOKIE_NAME'] = "MW_VER_1"
|
||||
Session(app)
|
||||
|
||||
# socketio
|
||||
from flask_socketio import SocketIO, emit, send
|
||||
socketio = SocketIO()
|
||||
socketio.init_app(app)
|
||||
|
||||
|
||||
# debug macosx dev
|
||||
if public.isAppleSystem():
|
||||
|
|
|
|||
16
setting.py
16
setting.py
|
|
@ -10,21 +10,25 @@ sys.path.append("/usr/local/lib/python2.7/site-packages")
|
|||
import public
|
||||
import system_api
|
||||
|
||||
cpu_info = system_api.system_api().getCpuInfo()
|
||||
# cpu_info = system_api.system_api().getCpuInfo()
|
||||
# workers = cpu_info[1] + 1
|
||||
workers = 1
|
||||
|
||||
|
||||
if not os.path.exists(os.getcwd() + '/logs'):
|
||||
os.mkdir(os.getcwd() + '/logs')
|
||||
|
||||
bt_port = public.readFile('data/port.pl')
|
||||
bind = ['0.0.0.0:%s' % bt_port]
|
||||
workers = cpu_info[1] + 1
|
||||
threads = 1
|
||||
|
||||
threads = 4
|
||||
backlog = 512
|
||||
reload = True
|
||||
reload = False
|
||||
daemon = True
|
||||
# worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker'
|
||||
worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker'
|
||||
timeout = 7200
|
||||
keepalive = 1
|
||||
keepalive = 60
|
||||
preload_app = True
|
||||
capture_output = True
|
||||
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
|
||||
loglevel = 'info'
|
||||
|
|
|
|||
Loading…
Reference in New Issue