Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
mdserver-web/plugins/openresty/index.py

59 lines
1.2 KiB

# coding:utf-8
import sys
import io
import os
import time
sys.path.append(os.getcwd() + "/class/core")
import public
def status():
data = public.execShell(
"ps -ef|grep openresty |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def start():
path = os.path.dirname(os.getcwd())
cmd = path + "/openresty/bin/openresty -c "
cmd = cmd + path + "/openresty/nginx/conf/nginx.conf"
data = public.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def stop():
path = os.path.dirname(os.getcwd())
cmd = path + "/openresty/bin/openresty -s stop"
data = public.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def reload():
path = os.path.dirname(os.getcwd())
cmd = path + "/openresty/bin/openresty -s reload"
data = public.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'reload':
print reload()
else:
print 'error'