Update index.py

This commit is contained in:
dami 2025-08-02 11:07:08 +08:00
parent ae64b70f10
commit ba65103df4
1 changed files with 13 additions and 13 deletions

View File

@ -84,7 +84,7 @@ def getPidFile():
return tmp.groups()[0].strip()
def status():
cmd = "ps aux|grep grafana |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
cmd = "ps aux|grep loki |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
data = mw.execShell(cmd)
if data[0] == '':
return 'stop'
@ -102,21 +102,21 @@ def contentReplace(content):
return content
def openPort():
try:
from utils.firewall import Firewall as MwFirewall
MwFirewall.instance().addAcceptPort('3000', 'grafana', 'port')
return port
except Exception as e:
return "Release failed {}".format(e)
return True
# def openPort():
# try:
# from utils.firewall import Firewall as MwFirewall
# MwFirewall.instance().addAcceptPort('3000', 'grafana', 'port')
# return port
# except Exception as e:
# return "Release failed {}".format(e)
# return True
def initDreplace():
# 初始化OP配置
init_file = getServerDir() + '/init.pl'
if not os.path.exists(init_file):
openPort()
# openPort()
mw.writeFile(init_file, 'ok')
# systemd
@ -160,7 +160,7 @@ def initdStatus():
if current_os == 'darwin':
return "Apple Computer does not support"
shell_cmd = 'systemctl status grafana|grep loaded|grep "enabled;"'
shell_cmd = 'systemctl status loki|grep loaded|grep "enabled;"'
data = mw.execShell(shell_cmd)
if data[0] == '':
return 'fail'
@ -172,7 +172,7 @@ def initdInstall():
if current_os == 'darwin':
return "Apple Computer does not support"
data = mw.execShell('systemctl enable grafana')
data = mw.execShell('systemctl enable loki')
if data[1] != '':
return data[1]
return 'ok'
@ -183,7 +183,7 @@ def initdUinstall():
if current_os == 'darwin':
return "Apple Computer does not support"
data = mw.execShell('systemctl disable grafana')
data = mw.execShell('systemctl disable loki')
if data[1] != '':
return data[1]
return 'ok'