Use `after-seconds` in supervise.rkt

This commit is contained in:
Tony Garnock-Jones 2024-05-27 15:16:48 +02:00
parent b59197f94b
commit 4ba9eee1c7
1 changed files with 3 additions and 9 deletions

View File

@ -7,8 +7,6 @@
default-restart-strategy)
(require syndicate/driver-support)
(define-logger syndicate/supervise)
(define-syntax-rule (supervise (main-proc-name arg ...))
@ -27,10 +25,6 @@
(spawn/link #:name (list 'supervised main-proc-name) (main-proc))))
(define ((default-restart-strategy [timeout-seconds 5] [plus-or-minus 1]) restart)
(react
(linked-thread
(lambda (facet)
(define t (+ timeout-seconds (* plus-or-minus (- (random) 0.5) 2)))
(log-syndicate/supervise-debug "restarting in ~v seconds" t)
(sleep t)
(turn! facet (lambda () (on-stop (restart))))))))
(define t (+ timeout-seconds (* plus-or-minus (- (random) 0.5) 2)))
(log-syndicate/supervise-debug "restarting in ~v seconds" t)
(after-seconds t (restart)))