2017-08-10 19:17:28 +00:00
|
|
|
#lang syndicate
|
2016-11-29 00:45:43 +00:00
|
|
|
;; Shows the difference between a supervised exit and a supervised crash.
|
|
|
|
|
|
|
|
(require/activate syndicate/supervise)
|
|
|
|
(require/activate syndicate/drivers/timestate)
|
|
|
|
|
|
|
|
(supervise
|
2016-11-29 01:47:22 +00:00
|
|
|
#:name 'ward-supervisor
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn #:name 'ward
|
2016-11-29 01:47:22 +00:00
|
|
|
(on-start (log-info "Starting ward"))
|
|
|
|
(on-stop (log-info "Stopping ward"))
|
2016-11-29 00:45:43 +00:00
|
|
|
(on (message 'crash)
|
|
|
|
(log-info "Crashing")
|
|
|
|
(error 'ward "Eep!"))
|
|
|
|
(stop-when (message 'quit)
|
|
|
|
(log-info "Bye!"))))
|
|
|
|
|
|
|
|
(define (monitor-interest-in thing)
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn #:name (list 'monitor-interest-in thing)
|
2016-11-29 00:45:43 +00:00
|
|
|
(during (observe thing)
|
|
|
|
(on-start (log-info "Interest in ~v appeared" thing))
|
|
|
|
(on-stop (log-info "Interest in ~v disappeared" thing)))))
|
|
|
|
|
|
|
|
(monitor-interest-in 'crash)
|
|
|
|
(monitor-interest-in 'quit)
|
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn* #:name 'main
|
2016-11-29 00:45:43 +00:00
|
|
|
(sleep 1)
|
|
|
|
(send! 'crash)
|
|
|
|
(sleep 1)
|
|
|
|
(send! 'quit)
|
|
|
|
(sleep 1))
|