Update index.py

pull/109/head
midoks 4 years ago
parent ed47878e33
commit 5b2786d37e
  1. 36
      plugins/swap/index.py

@ -66,32 +66,12 @@ def status():
def initDreplace(): def initDreplace():
return '/swapfile'
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
file_bin = initD_path + '/' + getPluginName()
# initd replace
content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
# config replace
conf_content = mw.readFile(getConf())
conf_content = conf_content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(getServerDir() + '/redis.conf', conf_content)
return file_bin
def start(): def start():
file = initDreplace() file = initDreplace()
data = mw.execShell(file + ' start') data = mw.execShell('swapon ' + file)
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return 'fail' return 'fail'
@ -99,28 +79,18 @@ def start():
def stop(): def stop():
file = initDreplace() file = initDreplace()
data = mw.execShell(file + ' stop') data = mw.execShell('swapoff ' + file)
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return 'fail' return 'fail'
def restart(): def restart():
file = initDreplace()
data = mw.execShell(file + ' restart')
log_file = getServerDir() + "/data/redis.log"
mw.execShell("echo '' > " + log_file)
if data[1] == '':
return 'ok' return 'ok'
return 'fail'
def reload(): def reload():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok' return 'ok'
return 'fail'
def initdStatus(): def initdStatus():

Loading…
Cancel
Save