Catch exn instead of exn:fail in daemon, to prevent accidental daemon exits.

This commit is contained in:
Tony Garnock-Jones 2014-12-04 12:20:23 -05:00
parent 0418e96196
commit db021c9551

View File

@ -8,12 +8,15 @@
(define (daemonize-thunk name boot-thunk) (define (daemonize-thunk name boot-thunk)
(lambda () (lambda ()
(let reboot () (let reboot ()
(with-handlers* ((exn:fail? (lambda (e) ;; We would catch exn:fail? here, but exn:pretty in the web
(log-error "*** DAEMON CRASHED: ~a ***\n~a" ;; server is a subtype of exn, not of exn:fail, and that causes
name ;; spurious permanent daemon exits.
(exn->string e)) (with-handlers* ((exn? (lambda (e)
(sleep 5) (log-error "*** DAEMON CRASHED: ~a ***\n~a"
(reboot)))) name
(exn->string e))
(sleep 5)
(reboot))))
(define result (boot-thunk)) (define result (boot-thunk))
(log-warning "Daemon thread ~a exited normally (returning ~v)" name result))))) (log-warning "Daemon thread ~a exited normally (returning ~v)" name result)))))