mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
Bug fix to email policy server.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env python2.7
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import os,sys
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
import django
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
import socket
|
||||
|
||||
import os
|
||||
import accept_traffic as handle
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
@@ -13,8 +14,11 @@ from cacheManager import cacheManager
|
||||
|
||||
|
||||
class SetupConn:
|
||||
cleaningPath = '/home/cyberpanel/purgeCache'
|
||||
server_address = ('localhost', 1089)
|
||||
cleaning_server = ('localhost', 1090)
|
||||
applicationPath = '/usr/local/CyberCP/postfixSenderPolicy/pid'
|
||||
cleaningServerPID = '/usr/local/CyberCP/postfixSenderPolicy/cpid'
|
||||
|
||||
|
||||
def __init__(self, serv_addr):
|
||||
@@ -22,32 +26,40 @@ class SetupConn:
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
def setup_conn(self):
|
||||
|
||||
logging.writeToFile('Starting CyberPanel Email Policy Server!')
|
||||
self.sock.bind(SetupConn.server_address)
|
||||
self.sock.bind(self.server_addr)
|
||||
logging.writeToFile('CyberPanel Email Policy Server Successfully started!')
|
||||
|
||||
def start_listening(self):
|
||||
self.sock.listen(1)
|
||||
self.sock.listen(5)
|
||||
while True:
|
||||
# Wait for a connection
|
||||
logging.writeToFile('Waiting For Connection!')
|
||||
if os.path.exists(SetupConn.cleaningPath):
|
||||
readFromFile = open(SetupConn.cleaningPath, 'r')
|
||||
command = readFromFile.read()
|
||||
cacheManager.handlePurgeRequest(command)
|
||||
readFromFile.close()
|
||||
os.remove(SetupConn.cleaningPath)
|
||||
|
||||
connection, client_address = self.sock.accept()
|
||||
background = handle.HandleRequest(connection)
|
||||
background.start()
|
||||
|
||||
|
||||
def __del__(self):
|
||||
self.sock.close()
|
||||
logging.writeToFile('Closing open connections!')
|
||||
|
||||
|
||||
|
||||
def Main():
|
||||
writeToFile = open(SetupConn.applicationPath, 'w')
|
||||
writeToFile.write(str(os.getpid()))
|
||||
writeToFile.close()
|
||||
|
||||
for sig in (SIGABRT, SIGINT, SIGTERM):
|
||||
signal(sig, cacheManager.cleanUP)
|
||||
###
|
||||
|
||||
writeToFile = open(SetupConn.applicationPath, 'w')
|
||||
writeToFile.write(str(os.getpid()))
|
||||
writeToFile.close()
|
||||
|
||||
listenConn = SetupConn(SetupConn.server_address)
|
||||
listenConn.setup_conn()
|
||||
|
||||
Reference in New Issue
Block a user