Skip to content

Commit

Permalink
Host: Compress old log output files
Browse files Browse the repository at this point in the history
To prevent running out of disk space, compress old log files in the
runtime directories.
  • Loading branch information
skyjake committed Feb 1, 2013
1 parent 9e9574d commit ad2b45a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doomsday/host/doomsday-host
Expand Up @@ -277,6 +277,21 @@ def rebuildAndInstall():

msg('Successful rebuild from branch %s.' % branch)
return True


def logCleanup():
for sv in servers:
files = os.listdir(sv.runtime)
logs = []
for fn in files:
if fn[-4:] == '.out' and '-' in fn:
logs.append(fn)
logs.sort()
# Process all except the latest one.
logs = logs[:-1]
for log in logs:
fn = os.path.join(sv.runtime, log)
run('gzip -9 ' + fn)


def startInstance():
Expand Down Expand Up @@ -333,6 +348,9 @@ def main():

# Save the state.
pickle.dump(state, file(stateFn, 'wb'))

# Archive old log files.
logCleanup()

# We're done.
endInstance()
Expand Down

0 comments on commit ad2b45a

Please sign in to comment.