Make the statistician perform the shutdown after a final round of reporting.

This commit is contained in:
Tony Garnock-Jones 2014-05-04 16:20:21 -04:00
parent eb4f9099a7
commit 34fc018520
1 changed files with 4 additions and 2 deletions

View File

@ -22,6 +22,7 @@
(define Tconn (logbook-table E "server-connections" #:column-spec '(time-seconds connection-count)))
(define connection-count 0)
(define first-connection-seen? #f)
(define statistics-poll-interval 2000)
@ -34,6 +35,8 @@
;; (collect-garbage)
(write-logbook-datum! Tmem (list (/ now 1000.0) (current-memory-use)))
(write-logbook-datum! Tconn (list (/ now 1000.0) connection-count))
(when (and first-connection-seen? (zero? connection-count))
(exit 0))
(transition s
(send (set-timer 'statistician statistics-poll-interval 'relative)))]
[_ #f]))
@ -53,14 +56,13 @@
(define (connection in out)
(set! connection-count (+ connection-count 1))
(set! first-connection-seen? #t)
(spawn (lambda (e s)
(match e
[(message (event _ (list (? eof-object?))) _ _)
(close-input-port in)
(close-output-port out)
(set! connection-count (- connection-count 1))
(when (zero? connection-count)
(exit 0))
(transition s (quit))]
[(message (event _ (list line)) _ _)
(fprintf out "~a\n" line)