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