Megatest

Diff
Login

Differences From Artifact [f57c29e310]:

To Artifact [1694e7ccde]:


240
241
242
243
244
245
246



247
248
249
250
251
252

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
;; WARNING: This proc operates assuming that it is in the directory above the
;;          logs directory you wish to log-rotate.
;;
(define (common:rotate-logs)
  (if (not (directory-exists? "logs"))(create-directory "logs"))
  (directory-fold 
   (lambda (file rem)



     (let* ((fullname (conc "logs/" file))
            (file-age (- (current-seconds)(file-modification-time fullname))))
       (if (or (and (string-match "^.*.log" file)
  	          (> (file-size (conc "logs/" file)) 200000))
               (and (string-match "^server-.*.log" file)
                    (> (- (current-seconds) (file-modification-time (conc "logs/" file))(* 8 60 60 60)))))

  	   (let ((gzfile (conc "logs/" file ".gz")))
  	     (if (file-exists? gzfile)
  	         (begin
  	  	   (debug:print-info 0 *default-log-port* "removing " gzfile)
  		   (delete-file gzfile)))
  	     (debug:print-info 0 *default-log-port* "compressing " file)
  	     (system (conc "gzip logs/" file)))
       (if (> file-age (* (string->number (or (configf:lookup *configdat* "setup" "log-expire-days") "30")) 24 3600))
           (handle-exceptions
	     exn
             #f
             (delete-file fullname)))))) 
   '()
   "logs"))

;; Force a megatest cleanup-db if version is changed and skip-version-check not specified
;;
(define (common:exit-on-version-changed)
  (if (common:version-changed?)







>
>
>
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|







240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
;; WARNING: This proc operates assuming that it is in the directory above the
;;          logs directory you wish to log-rotate.
;;
(define (common:rotate-logs)
  (if (not (directory-exists? "logs"))(create-directory "logs"))
  (directory-fold 
   (lambda (file rem)
     (handle-exceptions
      exn
      (debug:print-info 0 *default-log-port* "failed to rotate log " file ", probably handled by another process.")
      (let* ((fullname (conc "logs/" file))
             (file-age (- (current-seconds)(file-modification-time fullname))))
        (if (or (and (string-match "^.*.log" file)
                     (> (file-size fullname) 200000))
                (and (string-match "^server-.*.log" file)
                     (> (- (current-seconds) (file-modification-time fullname))
                        (* 8 60 60))))
            (let ((gzfile (conc fullname ".gz")))
              (if (file-exists? gzfile)
                  (begin
                    (debug:print-info 0 *default-log-port* "removing " gzfile)
                    (delete-file gzfile)))
              (debug:print-info 0 *default-log-port* "compressing " file)
              (system (conc "gzip " fullname)))
            (if (> file-age (* (string->number (or (configf:lookup *configdat* "setup" "log-expire-days") "30")) 24 3600))
                (handle-exceptions
                 exn
                 #f
                 (delete-file fullname)))))))
   '()
   "logs"))

;; Force a megatest cleanup-db if version is changed and skip-version-check not specified
;;
(define (common:exit-on-version-changed)
  (if (common:version-changed?)