mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-05 04:46:07 +01:00
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
from CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
|
import subprocess
|
|
import shlex
|
|
|
|
|
|
|
|
class ProcessUtilities:
|
|
litespeedProcess = "litespeed"
|
|
|
|
@staticmethod
|
|
def getLitespeedProcessNumber():
|
|
finalListOfProcesses = []
|
|
|
|
try:
|
|
import psutil
|
|
for proc in psutil.process_iter():
|
|
if proc.name() == ProcessUtilities.litespeedProcess:
|
|
finalListOfProcesses.append(proc.pid)
|
|
|
|
except BaseException,msg:
|
|
logging.writeToFile(
|
|
str(msg) + " [getLitespeedProcessNumber]")
|
|
return 0
|
|
|
|
if len(finalListOfProcesses) > 0:
|
|
return finalListOfProcesses
|
|
else:
|
|
return 0
|
|
|
|
@staticmethod
|
|
def restartLitespeed():
|
|
try:
|
|
command = "sudo systemctl restart lsws"
|
|
cmd = shlex.split(command)
|
|
res = subprocess.call(cmd)
|
|
|
|
if res == 0:
|
|
return 1
|
|
else:
|
|
return 0
|
|
|
|
except subprocess.CalledProcessError,msg:
|
|
logging.writeToFile(str(msg) + "[restartLitespeed]")
|
|
|
|
@staticmethod
|
|
def stopLitespeed():
|
|
try:
|
|
command = "sudo systemctl stop lsws"
|
|
cmd = shlex.split(command)
|
|
res = subprocess.call(cmd)
|
|
|
|
if res == 0:
|
|
return 1
|
|
else:
|
|
return 0
|
|
|
|
except subprocess.CalledProcessError, msg:
|
|
logging.writeToFile(str(msg) + "[stopLitespeed]")
|
|
|
|
|