.BANCHO. Add file buffers
This commit is contained in:
@@ -63,12 +63,7 @@ def logMessage(message, alertType = "INFO", messageColor = bcolors.ENDC, discord
|
||||
|
||||
# Log to file if needed
|
||||
if of is not None:
|
||||
try:
|
||||
glob.fLocks.lockFile(of)
|
||||
with open(".data/{}".format(of), "a") as f:
|
||||
f.write(finalMessage+ENDL)
|
||||
finally:
|
||||
glob.fLocks.unlockFile(of)
|
||||
glob.fileBuffers.write(".data/"+of, finalMessage+ENDL)
|
||||
|
||||
def warning(message, discord = None, alertDev = False):
|
||||
"""
|
||||
|
@@ -1,14 +1,25 @@
|
||||
from objects import glob
|
||||
from constants import serverPackets
|
||||
from helpers import consoleHelper
|
||||
import psutil
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import signal
|
||||
from helpers import logHelper as log
|
||||
from constants import bcolors
|
||||
import time
|
||||
import math
|
||||
|
||||
def dispose():
|
||||
"""
|
||||
Perform some clean up. Called on shutdown.
|
||||
:return:
|
||||
"""
|
||||
print("> Disposing server... ")
|
||||
glob.fileBuffers.flushAll()
|
||||
consoleHelper.printColored("Goodbye!", bcolors.GREEN)
|
||||
|
||||
def runningUnderUnix():
|
||||
"""
|
||||
Get if the server is running under UNIX or NT
|
||||
@@ -49,11 +60,13 @@ def scheduleShutdown(sendRestartTime, restart, message = "", delay=20):
|
||||
def restartServer():
|
||||
"""Restart pep.py script"""
|
||||
log.info("Restarting pep.py...")
|
||||
dispose()
|
||||
os.execv(sys.executable, [sys.executable] + sys.argv)
|
||||
|
||||
def shutdownServer():
|
||||
"""Shutdown pep.py"""
|
||||
log.info("Shutting down pep.py...")
|
||||
dispose()
|
||||
sig = signal.SIGKILL if runningUnderUnix() else signal.CTRL_C_EVENT
|
||||
os.kill(os.getpid(), sig)
|
||||
|
||||
|
Reference in New Issue
Block a user