-(define* (ez-run-hive hive initial-tasks #:key repl-server)
- "Start up an agenda and run HIVE in it with INITIAL-TASKS.
-
-Should we start up a cooperative REPL for live hacking? REPL-SERVER
-wants to know! You can pass it #t or #f, or if you want to specify a port,
-an integer."
- (let* ((queue (list->q initial-tasks))
- (agenda (make-agenda #:pre-unwind-handler print-error-and-continue
- #:queue queue)))
- (cond
- ;; If repl-server is an integer, we'll use that as the port
- ((integer? repl-server)
- (spawn-and-queue-repl-server! agenda repl-server))
- (repl-server
- (spawn-and-queue-repl-server! agenda)))
- (start-agenda agenda)))
+(define* (run-hive hive initial-tasks
+ #:key (cleanup #t))
+ "Start up an agenda and run HIVE in it with INITIAL-TASKS."
+ (dynamic-wind
+ (const #f)
+ (lambda ()
+ (let* ((queue (list->q initial-tasks))
+ (agenda (make-agenda #:pre-unwind-handler print-error-and-continue
+ #:queue queue)))
+ (run-agenda agenda)))
+ ;; Run cleanup
+ (lambda ()
+ (when cleanup
+ (run-hive-cleanup hive)))))
+
+(define (run-hive-cleanup hive)
+ (let ((queue (list->q (list (bootstrap-message hive (actor-id hive)
+ '*cleanup-all*)))))
+ (run-agenda
+ (make-agenda #:queue queue))))