pull/109/head
Mr Chen 6 years ago
parent 0d87e8e831
commit 36693178ef
  1. 3
      plugins/memcached/index.html
  2. 36
      plugins/memcached/index.py
  3. 4
      plugins/mysql/index.py

@ -3,7 +3,8 @@
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('memcached');">服务</p>
<p onclick="pluginInitD('memcached');">自启动</p>
<p onclick="pluginConfig('memcached');">配置修改</p>
<p onclick="pluginConfig('memcached', null, 'conf_tpl');">配置模板</p>
<p onclick="pluginConfig('memcached');">配置文件</p>
<p onclick="memcachedStatus();">负载状态</p>
<p onclick="memcachedCache();">性能调整</p>
</div>

@ -4,12 +4,13 @@ import sys
import io
import os
import time
import re
sys.path.append(os.getcwd() + "/class/core")
import public
app_debug = False
if public.getOs() == 'darwin':
if public.isAppleSystem():
app_debug = True
@ -32,16 +33,37 @@ def getInitDFile():
def getConf():
path = getServerDir() + "/init.d/memcached"
return path
def getConfTpl():
path = getPluginDir() + "/init.d/memcached.tpl"
return path
def getMemPort():
path = getConf()
content = public.readFile(path)
rep = 'PORT\s*=\s*(\d*)'
tmp = re.search(rep, content)
return tmp.groups()[0]
def getArgs():
args = sys.argv[2:]
tmp = {}
for i in range(len(args)):
t = args[i].split(':')
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
@ -55,7 +77,7 @@ def status():
def initDreplace():
file_tpl = getConf()
file_tpl = getConfTpl()
service_path = public.getServerDir()
initD_path = getServerDir() + '/init.d'
@ -110,9 +132,9 @@ def runInfo():
# 获取memcached状态
import telnetlib
import re
port = getMemPort()
try:
tn = telnetlib.Telnet('127.0.0.1', 11211)
tn = telnetlib.Telnet('127.0.0.1', int(port))
tn.write(b"stats\n")
tn.write(b"quit\n")
data = tn.read_all()
@ -221,6 +243,8 @@ if __name__ == "__main__":
print runInfo()
elif func == 'conf':
print getConf()
elif func == 'conf_tpl':
print getConfTpl()
elif func == 'save_conf':
print saveConf()
else:

@ -188,11 +188,11 @@ def status():
def start():
initMysql = getServerDir() + '/scripts/mysql_install_db ' + '--basedir=' + \
getServerDir() + ' --datadir=' + getServerDir() + '/bin/mysql/data'
# return initMysql
return initMysql
cmd = getServerDir() + '/bin/mysqld_safe ' + getServerDir() + \
'/conf/my.cnf ' + '--user=mysql&'
return cmd
# return cmd
data = public.execShell(cmd)
if data[0] == '':
return 'stop'

Loading…
Cancel
Save