29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
(begin
(debug:print 1 "Remote failed for " proc " " params)
(apply (eval (string->symbol proc)) params))
(if *runremote*
(apply (eval (string->symbol (conc "remote:" procstr))) params)
(eval (string->symbol procstr) params))))
(define (server:start db)
(debug:print 0 "Attempting to start the server ...")
(let* ((rpc:listener (server:find-free-port-and-open (rpc:default-server-port)))
(th1 (make-thread
(cute (rpc:make-server rpc:listener) "rpc:server")
'rpc:server))
(hostname (get-host-name))
(ipaddr (hostname->ip hostname))
(ipaddrstr (string-intersperse (map number->string (u8vector->list ipaddr)) "."))
(ipaddrstr:port (conc ipaddrstr ":" (rpc:default-server-port))))
(db:set-var db "SERVER" ipaddrstr:port)
(rpc:publish-procedure!
'remote:run
(lambda (procstr . params)
(server:autoremote procstr params)))
;;======================================================================
;; db specials here
|
|
|
>
|
>
|
>
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
(begin
(debug:print 1 "Remote failed for " proc " " params)
(apply (eval (string->symbol proc)) params))
(if *runremote*
(apply (eval (string->symbol (conc "remote:" procstr))) params)
(eval (string->symbol procstr) params))))
(define (server:start db hostn)
(debug:print 0 "Attempting to start the server ...")
(let* ((rpc:listener (server:find-free-port-and-open (rpc:default-server-port)))
(th1 (make-thread
(cute (rpc:make-server rpc:listener) "rpc:server")
'rpc:server))
(hostname (if (string=? "-" hostn)
(get-host-name)
hostn))
(ipaddrstr (if (string=? "-" hostn)
(string-intersperse (map number->string (u8vector->list (hostname->ip hostname))) ".")
#f))
(host:port (conc (if ipaddrstr ipaddrstr hostname) ":" (rpc:default-server-port))))
(db:set-var db "SERVER" host:port)
(rpc:publish-procedure!
'remote:run
(lambda (procstr . params)
(server:autoremote procstr params)))
;;======================================================================
;; db specials here
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
(rpc:publish-procedure!
'rpc:test-set-log!
(lambda (run-id test-name item-path logf)
(db:test-set-log! db run-id test-name item-path logf)))
(set! *rpc:listener* rpc:listener)
(on-exit (lambda ()
(sqlite3:execute db "DELETE FROM metadat WHERE var='SERVER' and val=?;" ipaddrstr:port)
(sqlite3:finalize! db)))
(thread-start! th1)
(thread-join! th1))) ;; rpc:server)))
(define (server:find-free-port-and-open port)
(handle-exceptions
exn
|
|
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
(rpc:publish-procedure!
'rpc:test-set-log!
(lambda (run-id test-name item-path logf)
(db:test-set-log! db run-id test-name item-path logf)))
(set! *rpc:listener* rpc:listener)
(on-exit (lambda ()
(sqlite3:execute db "DELETE FROM metadat WHERE var='SERVER' and val=?;" host:port)
(sqlite3:finalize! db)))
(thread-start! th1)
(thread-join! th1))) ;; rpc:server)))
(define (server:find-free-port-and-open port)
(handle-exceptions
exn
|