Dolda2000 GitWeb
/
doldaconnect.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f5b0faa
)
Made hubmgr daemonizable.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Tue, 13 Nov 2007 14:00:57 +0000
(15:00 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Tue, 13 Nov 2007 14:00:57 +0000
(15:00 +0100)
lib/guile/hubmgr
patch
|
blob
|
blame
|
history
diff --git
a/lib/guile/hubmgr
b/lib/guile/hubmgr
index
48c2b65
..
dd15213
100755
(executable)
--- a/
lib/guile/hubmgr
+++ b/
lib/guile/hubmgr
@@
-19,7
+19,7
@@
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(use-modules (dolcon ui) (dolcon util))
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(use-modules (dolcon ui) (dolcon util))
-(use-modules (ice-9 format) (ice-9 rdelim))
+(use-modules (ice-9 format) (ice-9 rdelim)
(ice-9 getopt-long)
)
(define max-hubs 6)
(define hub-list '())
(define max-hubs 6)
(define hub-list '())
@@
-27,10
+27,12
@@
(define hublist '())
(define connlist '())
(define statelist '())
(define hublist '())
(define connlist '())
(define statelist '())
+(define logdest #t)
(define (logf . args)
(let ((fmt (car args)) (args (cdr args)))
(define (logf . args)
(let ((fmt (car args)) (args (cdr args)))
- (apply format (cons* #t (string-append fmt "~%") args))))
+ (if logdest
+ (apply format (cons* logdest (string-append fmt "~%") args)))))
(define (list-delta l1 l2)
(let ((r1 '()) (r2 '()))
(define (list-delta l1 l2)
(let ((r1 '()) (r2 '()))
@@
-90,11
+92,14
@@
hublist))
(define (hubmgr-main args)
hublist))
(define (hubmgr-main args)
- (let ((dc-server #f))
+ (let ((opts (getopt-long args '((daemon (single-char #\d) (value #f))
+ (server (single-char #\s) (value #t))))))
+
(set! hublist (read-hl))
(logf "read ~a hubs" (length hublist))
(set! hublist (read-hl))
(logf "read ~a hubs" (length hublist))
- (dc-c&l #t
dc-server
#t)
+ (dc-c&l #t
(option-ref opts 'server #f)
#t)
(dc-ecmd-assert 200 "notify" "fn:act" "on")
(dc-ecmd-assert 200 "notify" "fn:act" "on")
+ (dc-ecmd-assert 200 "register" "hubmgr")
(dc-handle-fn)
(dc-fnproc-reg 'state (lambda (fn)
(if (and (eq? (cdr (assq 'state fn)) 'dead)
(dc-handle-fn)
(dc-fnproc-reg 'state (lambda (fn)
(if (and (eq? (cdr (assq 'state fn)) 'dead)
@@
-112,6
+117,11
@@
(cklist)))
(dc-loop-reg ".periodic" #f cklist)
(cklist)))
(dc-loop-reg ".periodic" #f cklist)
+ (if (and (option-ref opts 'daemon #f)
+ (not (= (primitive-fork) 0)))
+ (primitive-exit 0)
+ (set! logdest #f))
+
(cklist)
(dc-loop)))
(cklist)
(dc-loop)))