From 212af9eee61d211efb966bba7602673f8d782cc7 Mon Sep 17 00:00:00 2001 From: Martin Langhoff Date: Fri, 13 Sep 2013 12:50:05 -0400 Subject: [PATCH] compresslog now working correctly Tested to flush correctly / not lose any data in these scenarios - SIGUSR1 compresslog - SIGTERM compresslog - apache stop / restart - SIGTERM httpd - SIGKILL httpd of course if we SIGKILL compresslog it will lose whatever it has buffered --- compresslog.py | 97 +++++++++++++++++++++++----------------------------------- 1 file changed, 38 insertions(+), 59 deletions(-) rewrite compresslog.py (66%) diff --git a/compresslog.py b/compresslog.py dissimilarity index 66% index 7ab3062..e1e099a 100755 --- a/compresslog.py +++ b/compresslog.py @@ -1,59 +1,38 @@ -#!/usr/bin/python - -import sys -import signal -import zlib -import time -import struct - -# init globals used in sig handler -compressor = zlib.compressobj() - -def flushall(): - buf = compressor.flush(zlib.Z_FULL_FLUSH) - sys.stdout.write(buf) - sys.stdout.flush() - -def sig_flush(signum, frame): - flushall() - -def sig_flushexit(signum, frame): - flushall() - sys.exit() - -# gzip utilities cribbed from GZip module - -def write32u(output, value): - # The L format writes the bit pattern correctly whether signed - # or unsigned. - output.write(struct.pack("