Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -34,12 +34,12 @@ (define *incoming-data* '()) (define *incoming-last-time* (current-seconds)) (define *incoming-mutex* (make-mutex)) (define *cache-on* #f) -(define (open-db) ;; (conc *toppath* "/megatest.db") (car *configinfo*))) - (let* ((dbpath (conc *toppath* "/megatest.db")) ;; fname) +(define (open-db #!key (path #f)) ;; (conc *toppath* "/megatest.db") (car *configinfo*))) + (let* ((dbpath (conc (if path path *toppath*) "/megatest.db")) ;; fname) (dbexists (file-exists? dbpath)) (db (sqlite3:open-database dbpath)) ;; (never-give-up-open-db dbpath)) (handler (make-busy-timeout (if (args:get-arg "-override-timeout") (string->number (args:get-arg "-override-timeout")) 36000)))) ;; 136000))) Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -348,17 +348,19 @@ ;; set up the very basics needed for doing anything here. (define (setup-for-run) ;; would set values for KEYS in the environment here for better support of env-override but ;; have chicken/egg scenario. need to read megatest.config then read it again. Going to ;; pass on that idea for now. - (set! *configinfo* (find-and-read-config (if (args:get-arg "-config")(args:get-arg "-config") "megatest.config") environ-patt: "env-override")) - (set! *configdat* (if (car *configinfo*)(car *configinfo*) #f)) - (set! *toppath* (if (car *configinfo*)(cadr *configinfo*) #f)) - (if *toppath* - (setenv "MT_RUN_AREA_HOME" *toppath*) ;; to be deprecated - (debug:print 0 "ERROR: failed to find the top path to your run setup.")) - *toppath*) + (find-and-read-config (if (args:get-arg "-config") + (args:get-arg "-config") + "megatest.config") + environ-patt: "env-override")) + ;; (*configdat* (if (car *configinfo*)(car *configinfo*) #f)) + ;; (*toppath* (if (car *configinfo*)(cadr *configinfo*) #f))) + ;; (if *toppath* + ;; (setenv "MT_RUN_AREA_HOME" *toppath*) ;; to be deprecated + ;; (debug:print 0 "ERROR: failed to find the top path to your run setup.")) (define (get-best-disk confdat) (let* ((disks (hash-table-ref/default confdat "disks" #f)) (best #f) (bestsize 0)) Index: process.scm ================================================================== --- process.scm +++ process.scm @@ -76,6 +76,37 @@ (if (eq? pid-val 0) (begin (thread-sleep! 2) (loop (+ i 1))) (values pid-val exit-status exit-code)))))) - + +;;====================================================================== +;; A persistent shell to which we can send many commands +;; WATCH for flush issues! +;; ALWAYS call with > /dev/null OR > logfile to cmd +;;====================================================================== +(define (cmdshell:make-shell cmd . params) + ;; (print "Called with cmd=" cmd ", proc=" proc ", params=" params) + (handle-exceptions + exn + (begin + (print "ERROR: Failed to run command: " cmd " " (string-intersperse params " ")) + #f) + (let-values (((fh fho pid) (if (null? params) + (process cmd) + (process cmd params)))) + (vector fh fho pid)))) + +;; WARNING!! This will fail horribly if varname or varvalue have escaped or quoted portions +(define (cmdshell:set-env-var cmdshell varname varvalue) + (with-output-to-port (vector-ref cmdshell 1) + (lambda () + (print "export " varname "=" varvalue)))) + +(define (cmdshell:run-cmd cmdshell cmd) + (with-output-to-port (vector-ref cmdshell 1) + (lambda () + (print cmd)))) + + ;; (close-input-port fh) + ;; (close-output-port fho) +