Combining log files does not actually work, removing functionality

This commit is contained in:
Griatch 2018-01-26 22:12:57 +01:00
parent 1befcb1699
commit 6e5f9e8d2e
4 changed files with 35 additions and 19 deletions

View file

@ -811,7 +811,13 @@ def start_evennia(pprofiler=False, sprofiler=False):
def _portal_not_running(fail): def _portal_not_running(fail):
print("Portal starting {}...".format("(under cProfile)" if pprofiler else "")) print("Portal starting {}...".format("(under cProfile)" if pprofiler else ""))
try: try:
Popen(portal_cmd, env=getenv(), bufsize=-1) if os.name == 'nt':
# Windows requires special care
create_no_window = 0x08000000
Popen(portal_cmd, env=getenv(), bufsize=-1,
createflags=create_no_window)
else:
Popen(portal_cmd, env=getenv(), bufsize=-1)
except Exception as e: except Exception as e:
print(PROCESS_ERROR.format(component="Portal", traceback=e)) print(PROCESS_ERROR.format(component="Portal", traceback=e))
_reactor_stop() _reactor_stop()

View file

@ -8,6 +8,7 @@ import os
import sys import sys
from twisted.internet import protocol from twisted.internet import protocol
from evennia.server.portal import amp from evennia.server.portal import amp
from django.conf import settings
from subprocess import Popen, STDOUT, PIPE from subprocess import Popen, STDOUT, PIPE
from evennia.utils import logger from evennia.utils import logger
@ -150,21 +151,32 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
""" """
# start the Server # start the Server
try: with open(settings.SERVER_LOG_FILE, 'a') as logfile:
process = Popen(server_twistd_cmd, env=getenv(), bufsize=-1, stdout=PIPE, stderr=STDOUT) try:
except Exception: if os.name == 'nt':
self.factory.portal.server_process_id = None # Windows requires special care
logger.log_trace() create_no_window = 0x08000000
return 0 process = Popen(server_twistd_cmd, env=getenv(), bufsize=-1,
# there is a short window before the server logger is up where we must stdout=logfile, stderr=STDOUT,
# catch the stdout of the Server or eventual tracebacks will be lost. creationflags=create_no_window)
with process.stdout as out: else:
logger.log_server(out.read()) process = Popen(server_twistd_cmd, env=getenv(), bufsize=-1,
stdout=logfile, stderr=STDOUT)
except Exception:
self.factory.portal.server_process_id = None
logger.log_trace()
logfile.flush()
return 0
# there is a short window before the server logger is up where we must
# catch the stdout of the Server or eventual tracebacks will be lost.
# with process.stdout as out:
# logger.log_server(out.readlines())
# store the pid and launch argument for future reference # store the pid and launch argument for future reference
self.factory.portal.server_process_id = process.pid self.factory.portal.server_process_id = process.pid
self.factory.portal.server_twistd_cmd = server_twistd_cmd self.factory.portal.server_twistd_cmd = server_twistd_cmd
return process.pid logfile.flush()
return process.pid
def wait_for_disconnect(self, callback, *args, **kwargs): def wait_for_disconnect(self, callback, *args, **kwargs):
""" """

View file

@ -184,8 +184,8 @@ class Portal(object):
application = service.Application('Portal') application = service.Application('Portal')
# custom logging # custom logging
logfile = settings.SERVER_LOG_FILE if settings.MERGE_LOGS else settings.PORTAL_LOG_FILE logfile = logger.WeeklyLogFile(os.path.basename(settings.PORTAL_LOG_FILE),
logfile = logger.WeeklyLogFile(os.path.basename(logfile), os.path.dirname(logfile)) os.path.dirname(settings.PORTAL_LOG_FILE))
application.setComponent(ILogObserver, logger.PortalLogObserver(logfile).emit) application.setComponent(ILogObserver, logger.PortalLogObserver(logfile).emit)
# The main Portal server program. This sets up the database # The main Portal server program. This sets up the database

View file

@ -134,8 +134,6 @@ LOG_DIR = os.path.join(GAME_DIR, 'server', 'logs')
SERVER_LOG_FILE = os.path.join(LOG_DIR, 'server.log') SERVER_LOG_FILE = os.path.join(LOG_DIR, 'server.log')
PORTAL_LOG_FILE = os.path.join(LOG_DIR, 'portal.log') PORTAL_LOG_FILE = os.path.join(LOG_DIR, 'portal.log')
HTTP_LOG_FILE = os.path.join(LOG_DIR, 'http_requests.log') HTTP_LOG_FILE = os.path.join(LOG_DIR, 'http_requests.log')
# if this is true, merge logs into only the SERVER_LOG_FILE location.
MERGE_LOGS = True
# if this is set to the empty string, lockwarnings will be turned off. # if this is set to the empty string, lockwarnings will be turned off.
LOCKWARNING_LOG_FILE = os.path.join(LOG_DIR, 'lockwarnings.log') LOCKWARNING_LOG_FILE = os.path.join(LOG_DIR, 'lockwarnings.log')
# Rotate log files when server and/or portal stops. This will keep log # Rotate log files when server and/or portal stops. This will keep log