From c6753ed8974da8090037a52d65415143ebf1c015 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Mon, 5 Mar 2012 22:27:22 +0100 Subject: ebus-racket: tcp repl (--tcp-repl ) --- ebus-racket/inserter.rkt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ebus-racket/inserter.rkt') diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt index 9aaca78..a2ee1a0 100755 --- a/ebus-racket/inserter.rkt +++ b/ebus-racket/inserter.rkt @@ -6,7 +6,8 @@ racket/match "db.rkt" "layer7.rkt" - "layer2.rkt") + "layer2.rkt" + "tcp-repl.rkt") (define logger (make-logger 'ebus-inserter (current-logger))) @@ -41,6 +42,8 @@ (flush-output)]) (loop)))))) +(define-namespace-anchor repl-ns-anchor) + (define (main) ;; Parse commandline (command-line @@ -48,6 +51,8 @@ [("-c" "--connect") host port "Connect to server " (connect-host? host) (connect-port? (string->number port))] + ["--tcp-repl" port "Open REPL on TCP " + (tcp-repl-run (namespace-anchor->namespace repl-ns-anchor) (string->number port))] ["--debug-layer2" "Log level for Layer 2 Parser" (loglevel-layer2? 'debug)] ["--debug-db" "Log level for DB" @@ -67,18 +72,19 @@ (start-logger-thread (make-log-receiver logger 'info) (make-log-receiver db-logger (loglevel-db?)) (make-log-receiver layer2-logger (loglevel-layer2?)) - (make-log-receiver layer7-logger 'info)) + (make-log-receiver layer7-logger 'info) + (make-log-receiver tcp-repl-logger 'info)) ;; Test Database Connection (when (not (db-pgc-test)) - (display "Failed to connect database") + (log-message logger 'fatal "Failed to connect to database" #t) (exit 1)) ;; Connect, replacing input with tcp connection (if (or (null? (connect-host?)) (null? (connect-port?))) (log-message (current-logger) 'info "Using stdin" #t) (let-values ([(cin cout) (tcp-connect (connect-host?) (connect-port?))]) - (display (format "Connected to ~s ~s ~n" (connect-host?) (connect-port?))) + (log-message logger 'info (format "Connected to ~s ~s ~n" (connect-host?) (connect-port?)) #t) (current-input-port cin))) ;; Process Ebus Packets -- cgit v1.2.1