Updated examples to be compatible with new architecture.
[sam.git] / sam.scm
diff --git a/sam.scm b/sam.scm
index 93906b9..1d23712 100644 (file)
--- a/sam.scm
+++ b/sam.scm
@@ -11,6 +11,7 @@
         (chicken port)
         (chicken process-context)
         (chicken file)
+        (chicken condition)
         matchable
         srfi-18 ; threads
         srfi-69 ; hash-table
 (define (boot-sam)
   (start-console)
   (start-network-listener)
-  (send-message (make-actor main-beh) (make-actor system-beh))
+  (let ((system (make-actor system-beh))
+        (main #f))
+    (condition-case
+        (begin
+          (set! main (make-actor main-beh)))
+      ((exn)
+       (print "Error starting main actor. Is main-beh defined?")
+       (exit 1)))
+    (send-message main system))
   (start-scheduler))
 
 (define (print-usage)
      (loop rest))
     (((or "-n" "--hostname") hstr rest ...)
      (set! sam-host hstr)
-     (loop rest)
-    (((? file-exists? filename) rest ...))
+     (loop rest))
+    (((? file-exists? filename) rest ...)
      (print* "Loading " filename "...")
      (load filename)
      (print " done.")
      (loop rest))
     (()
-     (boot-sam host port main-beh))
+     (boot-sam))
     (else
      (print "Unrecognised argument '" (car args) "'.\n")
      (print-usage))))