Overview
Comment: | Changed gzip logic in log rotation to not touch server logs unless they are old. Bumped version to v1.6563 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.65 | v1.6563 |
Files: | files | file ages | folders |
SHA1: |
d495e1aac3cfce773252831d4b86161a |
User & Date: | mrwellan on 2020-08-19 11:33:53 |
Other Links: | branch diff | manifest | tags |
Context
2020-08-19
| ||
11:41 | merged fork check-in: 4ff27cb772 user: mmgraham tags: v1.65 | |
11:33 | Changed gzip logic in log rotation to not touch server logs unless they are old. Bumped version to v1.6563 check-in: d495e1aac3 user: mrwellan tags: v1.65, v1.6563 | |
10:26 | Changed gzip logic in log rotation to not touch server logs unless they are old. Bumped version to v1.6563 check-in: c5adf1640d user: mrwellan tags: v1.65 | |
Changes
Modified common.scm from [2cb67526d4] to [af38f0fd65].
︙ | ︙ | |||
489 490 491 492 493 494 495 | (debug:print-info 2 *default-log-port* "unable to rotate log " file ", probably handled by another process, this is safe to ignore.") (debug:print 2 *default-log-port* " message: " ((condition-property-accessor 'exn 'message) exn)) ;; (print-call-chain (current-error-port)) ;; ) (let* ((fullname (conc "logs/" file)) (mod-time (file-modification-time fullname)) (file-age (- (current-seconds) mod-time)) | | | > | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | (debug:print-info 2 *default-log-port* "unable to rotate log " file ", probably handled by another process, this is safe to ignore.") (debug:print 2 *default-log-port* " message: " ((condition-property-accessor 'exn 'message) exn)) ;; (print-call-chain (current-error-port)) ;; ) (let* ((fullname (conc "logs/" file)) (mod-time (file-modification-time fullname)) (file-age (- (current-seconds) mod-time)) (file-old (> file-age (* 48 60 60))) (file-big (> (file-size fullname) 200000))) (hash-table-set! all-files file mod-time) (if (or (and (string-match "^.*.log" file) file-old file-big) (and (string-match "^server-.*.log" file) file-old)) (let ((gzfile (conc fullname ".gz"))) (if (common:file-exists? gzfile) (begin (debug:print-info 0 *default-log-port* "removing " gzfile) (delete-file* gzfile) (hash-table-delete! all-files gzfile) ;; needed? )) (debug:print-info 0 *default-log-port* "compressing " file) (system (conc "gzip " fullname)) (inc-stat "gzipped") (hash-table-set! all-files (conc file ".gz") file-age) ;; add the .gz file and remove the base file (hash-table-delete! all-files file) ) (if (and (> file-age (* (string->number (or (configf:lookup *configdat* "setup" "log-expire-days") "30")) 24 3600)) (file-exists? fullname)) ;; just in case it was gzipped - will get it next time (handle-exceptions exn #f (if (directory? fullname) (begin (debug:print-error 0 *default-log-port* fullname " in logs directory is a directory! Cannot rotate it, it is best to not put subdirectories in the logs dir.") (inc-stat "directories")) |
︙ | ︙ |