Reverting changes to runner, instead adding settings.CYCLE_LOGFILES config variable.

This commit is contained in:
Griatch 2013-06-03 17:03:31 +02:00
parent 31410f5710
commit 340160e4ea
2 changed files with 23 additions and 3 deletions

View file

@ -55,6 +55,9 @@ PORTAL_PY_FILE = os.path.join(settings.SRC_DIR, 'server/portal.py')
# Get logfile names
SERVER_LOGFILE = settings.SERVER_LOG_FILE
PORTAL_LOGFILE = settings.PORTAL_LOG_FILE
HTTP_LOGFILE = settings.HTTP_LOG_FILE.strip()
CYCLE_LOGFILES = settings.CYCLE_LOGFILES
# Add this to the environmental variable for the 'twistd' command.
currpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -106,6 +109,18 @@ def get_pid(pidfile):
pid = f.read()
return pid
def cycle_logfile(logfile):
"""
Rotate the old log files to <filename>.old
"""
logfile_old = logfile + '.old'
if os.path.exists(logfile):
# Cycle the old logfiles to *.old
if os.path.exists(logfile_old):
# E.g. Windows don't support rename-replace
os.remove(logfile_old)
os.rename(logfile, logfile_old)
# Start program management
SERVER = None
@ -245,6 +260,8 @@ def main():
del server_argv[2]
print "\nStarting Evennia Server (output to stdout)."
else:
if CYCLE_LOGFILES:
cycle_logfile(SERVER_LOGFILE)
print "\nStarting Evennia Server (output to server logfile)."
if options.sprof:
server_argv.extend(sprof_argv)
@ -266,7 +283,9 @@ def main():
set_restart_mode(PORTAL_RESTART, True)
print "\nStarting Evennia Portal in non-Daemon mode (output to stdout)."
else:
PORTAL_LOGFILE
if CYCLE_LOGFILES:
cycle_logfile(PORTAL_LOGFILE)
cycle_logfile(HTTP_LOGFILE)
set_restart_mode(PORTAL_RESTART, False)
print "\nStarting Evennia Portal in Daemon mode (output to portal logfile)."
if options.pprof:

View file

@ -76,9 +76,10 @@ GAME_DIR = os.path.join(BASE_PATH, 'game')
LOG_DIR = os.path.join(GAME_DIR, 'logs')
SERVER_LOG_FILE = os.path.join(LOG_DIR, 'server.log')
PORTAL_LOG_FILE = os.path.join(LOG_DIR, 'portal.log')
# Where to log server requests to the web server. This is VERY spammy, so this
# file should be removed at regular intervals.
HTTP_LOG_FILE = os.path.join(LOG_DIR, 'http_requests.log')
# Rotate log files when server and/or portal stops. This will keep log file sizes down.
# Turn off to get ever growing log files and never loose log info.
CYCLE_LOGFILES = True
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.0/interactive/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'UTC'