mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
加入自启动选项功能
1.memcached 调整ok
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('memcached');">服务</p>
|
||||
<p onclick="pluginInitD('memcached');">自启动</p>
|
||||
<p onclick="pluginConfig('memcached');">配置修改</p>
|
||||
<p onclick="memcachedStatus();">负载状态</p>
|
||||
<p onclick="memcachedCache();">性能调整</p>
|
||||
|
||||
@@ -8,6 +8,8 @@ import time
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getAppName():
|
||||
return 'memcached'
|
||||
@@ -21,6 +23,12 @@ def getServerDir():
|
||||
return public.getServerDir() + '/' + getAppName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
if app_debug:
|
||||
return '/tmp/' + getAppName()
|
||||
return '/etc/init.d/' + getAppName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getPluginDir() + "/init.d/memcached.tpl"
|
||||
return path
|
||||
@@ -37,7 +45,7 @@ def getArgs():
|
||||
|
||||
def status():
|
||||
data = public.execShell(
|
||||
"ps -ef|grep memcached |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
"ps -ef|grep " + getAppName() + " |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
@@ -155,15 +163,43 @@ def saveConf():
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
if os.path.exists(initd_bin):
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
import shutil
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mem_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(mem_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
os.remove(initd_bin)
|
||||
return 'ok'
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'run_info':
|
||||
print runInfo()
|
||||
elif func == 'conf':
|
||||
print getConf()
|
||||
elif func == 'save_conf':
|
||||
print saveConf()
|
||||
elif func == 'status':
|
||||
if func == 'status':
|
||||
print status()
|
||||
elif func == 'start':
|
||||
print start()
|
||||
@@ -173,5 +209,17 @@ if __name__ == "__main__":
|
||||
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()
|
||||
elif func == 'run_info':
|
||||
print runInfo()
|
||||
elif func == 'conf':
|
||||
print getConf()
|
||||
elif func == 'save_conf':
|
||||
print saveConf()
|
||||
else:
|
||||
print 'fail'
|
||||
|
||||
Reference in New Issue
Block a user