mirror of https://github.com/midoks/mdserver-web
parent
b457c8b7c3
commit
b5fc0d3173
@ -0,0 +1,16 @@ |
|||||||
|
<div class="bt-form"> |
||||||
|
<div class="bt-w-main"> |
||||||
|
<div class="bt-w-menu"> |
||||||
|
<p class="bgw" onclick="pluginService('redis');">服务</p> |
||||||
|
<p onclick="pluginInitD('redis');">自启动</p> |
||||||
|
<p onclick="pluginConfig('redis');">配置修改</p> |
||||||
|
<p onclick="redisStatus();">负载状态</p> |
||||||
|
</div> |
||||||
|
<div class="bt-w-con pd15"> |
||||||
|
<div class="soft-man-con"></div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<script type="text/javascript"> |
||||||
|
pluginService('redis'); |
||||||
|
</script> |
@ -0,0 +1,172 @@ |
|||||||
|
# coding: utf-8 |
||||||
|
|
||||||
|
import time |
||||||
|
import random |
||||||
|
import os |
||||||
|
import urllib |
||||||
|
import binascii |
||||||
|
import json |
||||||
|
import re |
||||||
|
import sys |
||||||
|
import subprocess |
||||||
|
|
||||||
|
sys.path.append(os.getcwd() + "/class/core") |
||||||
|
import public |
||||||
|
|
||||||
|
|
||||||
|
app_debug = False |
||||||
|
if public.getOs() == 'darwin': |
||||||
|
app_debug = True |
||||||
|
|
||||||
|
|
||||||
|
def getPluginName(): |
||||||
|
return 'abkill' |
||||||
|
|
||||||
|
|
||||||
|
def getPluginDir(): |
||||||
|
return public.getPluginDir() + '/' + getPluginName() |
||||||
|
|
||||||
|
|
||||||
|
def getServerDir(): |
||||||
|
return public.getServerDir() + '/' + getPluginName() |
||||||
|
|
||||||
|
|
||||||
|
def getInitDFile(): |
||||||
|
if app_debug: |
||||||
|
return '/tmp/' + getPluginName() |
||||||
|
return '/etc/init.d/' + getPluginName() |
||||||
|
|
||||||
|
|
||||||
|
def getArgs(): |
||||||
|
args = sys.argv[2:] |
||||||
|
tmp = {} |
||||||
|
args_len = len(args) |
||||||
|
|
||||||
|
if args_len == 1: |
||||||
|
t = args[0].strip('{').strip('}') |
||||||
|
t = t.split(':') |
||||||
|
tmp[t[0]] = t[1] |
||||||
|
elif args_len > 1: |
||||||
|
for i in range(len(args)): |
||||||
|
t = args[i].split(':') |
||||||
|
tmp[t[0]] = t[1] |
||||||
|
|
||||||
|
return tmp |
||||||
|
|
||||||
|
|
||||||
|
def initDreplace(): |
||||||
|
initd_file = getInitDFile() |
||||||
|
|
||||||
|
if not os.path.exists(initd_file): |
||||||
|
return getServerDir() |
||||||
|
|
||||||
|
return initd_file |
||||||
|
|
||||||
|
|
||||||
|
def status(): |
||||||
|
data = public.execShell( |
||||||
|
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'") |
||||||
|
if data[0] == '': |
||||||
|
return 'stop' |
||||||
|
return 'start' |
||||||
|
|
||||||
|
|
||||||
|
def csvnOp(method): |
||||||
|
|
||||||
|
if app_debug: |
||||||
|
os_name = public.getOs() |
||||||
|
if os_name == 'darwin': |
||||||
|
return "Apple Computer does not support" |
||||||
|
|
||||||
|
_initd_csvn = '/etc/init.d/csvn' |
||||||
|
_initd_csvn_httpd = '/etc/init.d/csvn-httpd' |
||||||
|
#_csvn = getServerDir() + '/bin/csvn' |
||||||
|
#_csvn_httpd = getServerDir() + '/bin/csvn-httpd' |
||||||
|
|
||||||
|
ret_csvn_httpd = public.execShell(_initd_csvn_httpd + ' ' + method) |
||||||
|
# ret_csvn = public.execShell(_initd_csvn + ' ' + method) |
||||||
|
subprocess.Popen(_initd_csvn + ' ' + method, |
||||||
|
stdout=subprocess.PIPE, shell=True) |
||||||
|
if ret_csvn_httpd[1] == '': |
||||||
|
return 'ok' |
||||||
|
return 'fail' |
||||||
|
|
||||||
|
|
||||||
|
def start(): |
||||||
|
return csvnOp('start') |
||||||
|
|
||||||
|
|
||||||
|
def stop(): |
||||||
|
return csvnOp('stop') |
||||||
|
|
||||||
|
|
||||||
|
def restart(): |
||||||
|
return csvnOp('restart') |
||||||
|
|
||||||
|
|
||||||
|
def reload(): |
||||||
|
return csvnOp('reload') |
||||||
|
|
||||||
|
|
||||||
|
def initdStatus(): |
||||||
|
if not app_debug: |
||||||
|
if public.getOs() == 'darwin': |
||||||
|
return "Apple Computer does not support" |
||||||
|
|
||||||
|
_initd_csvn = '/etc/init.d/csvn' |
||||||
|
_initd_csvn_httpd = '/etc/init.d/csvn-httpd' |
||||||
|
|
||||||
|
if os.path.exists(_initd_csvn) and os.path.exists(_initd_csvn_httpd): |
||||||
|
return 'ok' |
||||||
|
return 'fail' |
||||||
|
|
||||||
|
|
||||||
|
def initdInstall(): |
||||||
|
import shutil |
||||||
|
if not app_debug: |
||||||
|
if public.getOs() == 'darwin': |
||||||
|
return "Apple Computer does not support" |
||||||
|
|
||||||
|
_csvn = getServerDir() + '/bin/csvn' |
||||||
|
_csvn_httpd = getServerDir() + '/bin/csvn-httpd' |
||||||
|
|
||||||
|
ret_csvn = public.execShell(_csvn + ' install') |
||||||
|
ret_csvn_httpd = public.execShell(_csvn_httpd + ' install') |
||||||
|
if ret_csvn[1] == '' and ret_csvn_httpd[1] == '': |
||||||
|
return 'ok' |
||||||
|
return 'fail' |
||||||
|
|
||||||
|
|
||||||
|
def initdUinstall(): |
||||||
|
if not app_debug: |
||||||
|
if public.getOs() == 'darwin': |
||||||
|
return "Apple Computer does not support" |
||||||
|
|
||||||
|
_csvn = getServerDir() + '/bin/csvn' |
||||||
|
_csvn_httpd = getServerDir() + '/bin/csvn-httpd' |
||||||
|
|
||||||
|
ret_csvn = public.execShell(_csvn + ' remove') |
||||||
|
ret_csvn_httpd = public.execShell(_csvn_httpd + ' remove') |
||||||
|
return 'ok' |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
func = sys.argv[1] |
||||||
|
if func == 'status': |
||||||
|
print status() |
||||||
|
elif func == 'start': |
||||||
|
print start() |
||||||
|
elif func == 'stop': |
||||||
|
print stop() |
||||||
|
elif func == 'restart': |
||||||
|
print restart() |
||||||
|
elif func == 'reload': |
||||||
|
print reload() |
||||||
|
elif func == 'initd_status': |
||||||
|
print initdStatus() |
||||||
|
elif func == 'initd_install': |
||||||
|
print initdInstall() |
||||||
|
elif func == 'initd_uninstall': |
||||||
|
print initdUinstall() |
||||||
|
else: |
||||||
|
print 'fail' |
@ -0,0 +1,31 @@ |
|||||||
|
#!/bin/bash |
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||||
|
export PATH |
||||||
|
|
||||||
|
curPath=`pwd` |
||||||
|
rootPath=$(dirname "$curPath") |
||||||
|
rootPath=$(dirname "$rootPath") |
||||||
|
serverPath=$(dirname "$rootPath") |
||||||
|
|
||||||
|
|
||||||
|
install_tmp=${rootPath}/tmp/bt_install.pl |
||||||
|
|
||||||
|
|
||||||
|
Install_abkill() |
||||||
|
{ |
||||||
|
echo '正在安装脚本文件...' > $install_tmp |
||||||
|
mkdir -p $serverPath/abkill |
||||||
|
echo '安装完成' > $install_tmp |
||||||
|
} |
||||||
|
Uninstall_abkill() |
||||||
|
{ |
||||||
|
rm -rf $serverPath/abkill |
||||||
|
echo "Uninstall_redis" > $install_tmp |
||||||
|
} |
||||||
|
|
||||||
|
action=$1 |
||||||
|
if [ "${1}" == 'install' ];then |
||||||
|
Install_abkill |
||||||
|
else |
||||||
|
Uninstall_abkill |
||||||
|
fi |
Loading…
Reference in new issue