Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -33,12 +33,12 @@ configfmod.scm commonmod.scm dbmod.scm rmtmod.scm \ debugprint.scm mtver.scm csv-xml.scm servermod.scm \ hostinfo.scm adjutant.scm processmod.scm testsmod.scm \ itemsmod.scm keysmod.scm mtmod.scm rmtmod.scm \ tasksmod.scm pgdb.scm launchmod.scm runsmod.scm \ - portloggermod.scm clientmod.scm archivemod.scm \ - ezstepsmod.scm subrunmod.scm bigmod.scm testsmod.scm + portloggermod.scm archivemod.scm ezstepsmod.scm \ + subrunmod.scm bigmod.scm testsmod.scm GUISRCF = dashboard-context-menu.scm dashboard-tests.scm \ dashboard-guimonitor.scm gutils.scm dcommon.scm tree.scm \ vg.scm @@ -63,11 +63,11 @@ mofiles/archivemod.o : mofiles/launchmod.o mofiles/archivemod.o : mofiles/servermod.o mofiles/bigmod.o : mofiles/configfmod.o mofiles/bigmod.o : mofiles/dbmod.o mofiles/bigmod.o : mofiles/rmtmod.o -mofiles/clientmod.o : mofiles/servermod.o +# mofiles/clientmod.o : mofiles/servermod.o mofiles/commonmod.o : mofiles/configfmod.o mofiles/commonmod.o : mofiles/debugprint.o mofiles/commonmod.o : mofiles/hostinfo.o mofiles/commonmod.o : mofiles/itemsmod.o mofiles/commonmod.o : mofiles/keysmod.o @@ -88,11 +88,11 @@ mofiles/launchmod.o : mofiles/rmtmod.o mofiles/servermod.o mofiles/mtmod.o : mofiles/debugprint.o mofiles/portloggermod.o : mofiles/tasksmod.o mofiles/rmtmod.o : mofiles/apimod.o mofiles/rmtmod.o : mofiles/commonmod.o mofiles/portloggermod.o -mofiles/rmtmod.o : mofiles/itemsmod.o mofiles/clientmod.o +mofiles/rmtmod.o : mofiles/itemsmod.o # mofiles/clientmod.o mofiles/runsmod.o : mofiles/rmtmod.o mofiles/archivemod.o mofiles/servermod.o : mofiles/commonmod.o mofiles/stml2.o : mofiles/cookie.o mofiles/dbi.o mofiles/tasksmod.o : mofiles/pgdb.o mofiles/dbmod.o mofiles/testsmod.o : mofiles/commonmod.o @@ -135,11 +135,10 @@ TCMTOBJS = \ api.o \ archive.o \ cgisetup/models/pgdb.o \ - client.o \ common.o \ configf.o \ db.o \ env.o \ http-transport.o \ @@ -410,12 +409,12 @@ fi if csi -ne '(import postgresql)';then \ echo "(import postgresql)(hash-table-set! *available-db* 'postgresql #t)" >> altdb.scm;\ fi -portlogger-example : portlogger-example.scm api.o archive.o client.o common.o configf.o dashboard-tests.o dashboard-context-menu.o db.o dcommon.o ezsteps.o filedb.o genexample.o gutils.o http-transport.o items.o keys.o launch.o lock-queue.o margs.o mt.o ods.o portlogger.o process.o rmt.o runconfig.o runs.o sdb.o server.o synchash.o tasks.o tdb.o tests.o tree.o - csc $(CSCOPTS) portlogger-example.scm api.o archive.o client.o common.o configf.o dashboard-tests.o dashboard-context-menu.o db.o dcommon.o ezsteps.o filedb.o genexample.o gutils.o http-transport.o items.o keys.o launch.o lock-queue.o margs.o mt.o ods.o portlogger.o process.o rmt.o runconfig.o runs.o sdb.o server.o synchash.o tasks.o tdb.o tests.o tree.o +portlogger-example : portlogger-example.scm api.o archive.o common.o configf.o dashboard-tests.o dashboard-context-menu.o db.o dcommon.o ezsteps.o filedb.o genexample.o gutils.o http-transport.o items.o keys.o launch.o lock-queue.o margs.o mt.o ods.o portlogger.o process.o rmt.o runconfig.o runs.o sdb.o server.o synchash.o tasks.o tdb.o tests.o tree.o + csc $(CSCOPTS) portlogger-example.scm api.o archive.o common.o configf.o dashboard-tests.o dashboard-context-menu.o db.o dcommon.o ezsteps.o filedb.o genexample.o gutils.o http-transport.o items.o keys.o launch.o lock-queue.o margs.o mt.o ods.o portlogger.o process.o rmt.o runconfig.o runs.o sdb.o server.o synchash.o tasks.o tdb.o tests.o tree.o buildmanual: cd docs/manual && make targets: Index: apimod.scm ================================================================== --- apimod.scm +++ apimod.scm @@ -49,10 +49,11 @@ tasksmod servermod matchable ) + ;; allow these queries through without starting a server ;; (define api:read-only-queries '(get-key-val-pairs get-var @@ -404,18 +405,17 @@ ;; db:* ;; ;; NB// Runs on the server as part of the server loop ;; (define (api:process-request dbstruct indat) ;; the $ is the request vars proc - (debug:print 0 *default-log-port* "server-id:" *server-id*) (let* ((cmd-in (alist-ref 'cmd indat)) ;; ($ 'cmd)) (cmd (if (string? cmd-in)(string->symbol cmd-in) cmd-in)) (params (string->sexpr (alist-ref 'params indat))) (key (alist-ref 'key indat)) ;; TODO - add this back ) (debug:print 0 *default-log-port* "cmd:" cmd " with params " params "key " key) - (if (equal? key *server-id*) ;; TODO - get real key involved + (if (equal? key *my-signature*) ;; TODO - get real key involved (begin (set! *api-process-request-count* (+ *api-process-request-count* 1)) (let* ((res (api:execute-requests dbstruct cmd params))) (debug:print 0 *default-log-port* "res:" res) #;(if (not success) @@ -423,9 +423,9 @@ (if (> *api-process-request-count* *max-api-process-requests*) (set! *max-api-process-requests* *api-process-request-count*)) (set! *api-process-request-count* (- *api-process-request-count* 1)) (sexpr->string res))) (begin - (debug:print 0 *default-log-port* "Server refused to process request. Sever id mismatch. recived " key " expected: " *server-id* ".\nOther arguments recived: cmd=" cmd " params = " params) - (sexpr->string (conc "Server refused to process request server-id mismatch: " key ", " *server-id*)))))) + (debug:print 0 *default-log-port* "Server refused to process request. Sever id mismatch. recived " key " expected: " *my-signature* ".\nOther arguments recived: cmd=" cmd " params = " params) + (sexpr->string (conc "Server refused to process request server signature mismatch: " key ", " *my-signature*)))))) ) Index: clientmod.scm ================================================================== --- clientmod.scm +++ clientmod.scm @@ -73,11 +73,11 @@ ;; ;; (include "common_records.scm") ;; (include "db_records.scm") ;; client:get-signature -(define (client:get-signature) +#;(define (client:get-signature) (if *my-client-signature* *my-client-signature* (let ((sig (conc (get-host-name) " " (current-process-id)))) (set! *my-client-signature* sig) *my-client-signature*))) Index: commonmod.scm ================================================================== --- commonmod.scm +++ commonmod.scm @@ -209,17 +209,17 @@ (define *db-api-call-time* (make-hash-table)) ;; hash of command => (list of times) ;; no sync db (define *no-sync-db* #f) ;; SERVER -(define *my-client-signature* #f) +(define *my-signature* #f) (define *transport-type* 'http) ;; override with [server] transport http|rpc|nmsg ;; replaced by *rmt:remote* ;; (define *runremote* #f) ;; if set up for server communication this will hold ;; (define *max-cache-size* 0) (define *logged-in-clients* (make-hash-table)) -(define *server-id* #f) +;; (define *server-id* #f) (define *server-info* #f) ;; good candidate for easily convert to non-global ;; (define *time-to-exit* #f) (define *server-run* #t) (define *run-id* #f) (define *server-kind-run* (make-hash-table)) Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -19,11 +19,10 @@ ;;====================================================================== (declare (unit rmtmod)) (declare (uses apimod)) -(declare (uses clientmod)) (declare (uses commonmod)) (declare (uses configfmod)) (declare (uses dbmod)) (declare (uses debugprint)) (declare (uses itemsmod)) @@ -234,11 +233,11 @@ fullname: fullpath hostport: srv-addr ipaddr: ipaddr port: port srvpkt: the-srv - srvkey: srv-key + srvkey: srv-key ;; not the same as signature lastmsg: (current-seconds) expires: (+ (current-seconds) 60) ;; this needs to be gathered during the ping )) #t) (start-main-srv))) @@ -385,11 +384,11 @@ ;;====================================================================== ;; M I S C ;;====================================================================== (define (rmt:login run-id) - (rmt:send-receive 'login run-id (list *toppath* megatest-version *my-client-signature*))) + (rmt:send-receive 'login run-id (list *toppath* megatest-version *my-signature*))) ;; rmt:login-no-auto-client-setup ;; rmt:send-receive-no-auto-client-setup ;; hand off a call to one of the db:queries statements @@ -1710,35 +1709,10 @@ ;; ;;(close-idle-connections!) ;; #t)) ;; #f))) -(define (make-http-transport:server-dat)(make-vector 6)) -(define (http-transport:server-dat-get-iface vec) (vector-ref vec 0)) -(define (http-transport:server-dat-get-port vec) (vector-ref vec 1)) -(define (http-transport:server-dat-get-api-uri vec) (vector-ref vec 2)) -(define (http-transport:server-dat-get-api-url vec) (vector-ref vec 3)) -(define (http-transport:server-dat-get-api-req vec) (vector-ref vec 4)) -(define (http-transport:server-dat-get-last-access vec) (vector-ref vec 5)) -;(define (http-transport:server-dat-get-socket vec) (vector-ref vec 6)) -(define (http-transport:server-dat-get-server-id vec) (vector-ref vec 6)) - -(define (http-transport:server-dat-make-url vec) - (if (and (http-transport:server-dat-get-iface vec) - (http-transport:server-dat-get-port vec)) - (conc "http://" - (http-transport:server-dat-get-iface vec) - ":" - (http-transport:server-dat-get-port vec)) - #f)) - -(define (http-transport:server-dat-update-last-access vec) - (if (vector? vec) - (vector-set! vec 5 (current-seconds)) - (begin - (print-call-chain (current-error-port)) - (debug:print-error 0 *default-log-port* "call to http-transport:server-dat-update-last-access with non-vector!!")))) ;; initialize servdat for client side, setup needed parameters ;; pass in #f as sdat-in to create sdat ;; #;(define (servdat-init sdat-in iface port uuid) @@ -2023,16 +1997,16 @@ (loop curr-host curr-port (+ tries 1))) ((< (- (current-seconds) stime) 1) ;; keep up the looping until at least 3 seconds have passed (thread-sleep! 0.5) (loop curr-host curr-port (+ tries 1))) (else - (if (not *server-id*)(set! *server-id* (server:mk-signature))) + (rmt:mk-signature) ;; sets *my-signature* as side effect (servdat-status-set! *server-info* 'interface-stable) (debug:print 0 *default-log-port* "SERVER STARTED: " curr-host ":" curr-port - " AT " (current-seconds) " server-id: " *server-id* + " AT " (current-seconds) " server signature: " *my-signature* " with "(servdat-trynum *server-info*)" port changes") (flush-output *default-log-port*) #t)))))) ;; run http-transport:keep-running in a parallel thread to monitor that the db is being @@ -2044,11 +2018,11 @@ ;; This thread waits for the server to come alive (debug:print-info 0 *default-log-port* "Starting the sync-back, keep alive thread in server") (let* ((server-start-time (current-seconds)) (pkts-dir (get-pkts-dir)) - (server-key (server:mk-signature)) + (server-key (rmt:mk-signature)) (is-main (equal? (args:get-arg "-db") ".db/main.db")) (last-access 0) (server-timeout (server:expiration-timeout))) ;; main and run db servers have both got wait logic (could/should merge it) (if is-main @@ -2192,24 +2166,25 @@ (exit)) #f ) -;; Generate a unique signature for this server -(define (server:mk-signature) +;; Generate a unique signature for this process, used at both client and +;; server side +(define (rmt:mk-signature) (message-digest-string (md5-primitive) (with-output-to-string (lambda () (write (list (current-directory) (current-process-id) (argv))))))) -(define (server:get-client-signature) - (if *my-client-signature* *my-client-signature* - (let ((sig (server:mk-signature))) - (set! *my-client-signature* sig) - *my-client-signature*))) +(define (rmt:get-signature) + (if *my-signature* *my-signature* + (let ((sig (rmt:mk-signature))) + (set! *my-signature* sig) + *my-signature*))) ;;====================================================================== ;; S E R V E R U T I L I T I E S ;;====================================================================== Index: testsmod.scm ================================================================== --- testsmod.scm +++ testsmod.scm @@ -1241,12 +1241,12 @@ ;; read data from tmp file or create if not exists ;; if exists regen in background ;; (define (tests:lazy-dot testrecords outtype sizex sizey) - (let ((dfile (conc "/tmp/." (current-user-name) "-" (server:mk-signature) ".dot")) - (fname (conc "/tmp/." (current-user-name) "-" (server:mk-signature) ".dotdat"))) + (let ((dfile (conc "/tmp/." (current-user-name) "-" (rmt:mk-signature) ".dot")) + (fname (conc "/tmp/." (current-user-name) "-" (rmt:mk-signature) ".dotdat"))) (tests:write-dot-file testrecords dfile sizex sizey) (if (common:file-exists? fname) (let ((res (with-input-from-file fname (lambda () (read-lines)))))