@@ -986,11 +986,11 @@ (if (args:get-arg "-list-servers") (let* ((tl (launch:setup)) ;; need this to initialize *toppath* (servdir (tt:get-servinfo-dir *toppath*)) (servfiles (glob (conc servdir "/*:*.db"))) (fmtstr "~10a~22a~10a~25a~25a~8a\n") - (dbfiles (glob (conc *toppath* "/.mtdb/*.db"))) + (dbfiles (append (glob (conc *toppath* "/.mtdb/main.db")) (glob (conc *toppath* "/.mtdb/?.db"))(glob (conc *toppath* "/.mtdb/??.db")))) (ttdat (make-tt areapath: *toppath*)) ) (format #t fmtstr "DB" "host:port" "PID" "age" "last mod" "state") (for-each (lambda (dbfile) @@ -1044,11 +1044,11 @@ (let* ((tl (launch:setup)) ;; need this to initialize *toppath* (servdir (tt:get-servinfo-dir *toppath*)) (servfiles (glob (conc servdir "/*:*.db"))) (fmtstr "~10a~22a~10a~25a~25a~8a\n") - (dbfiles (glob (conc *toppath* "/.mtdb/*.db"))) + (dbfiles (append (glob (conc *toppath* "/.mtdb/main.db")) (glob (conc *toppath* "/.mtdb/?.db"))(glob (conc *toppath* "/.mtdb/??.db")))) (ttdat (make-tt areapath: *toppath*)) ) (format #t fmtstr "DB" "host:port" "PID" "age" "last mod" "state") (for-each (lambda (dbfile) @@ -1074,11 +1074,11 @@ (killed (system (conc "ssh " host " kill " pid " > /dev/null"))) (dummy2 (sleep 1)) (state (if (> (system (conc "ssh " host " ps " pid " > /dev/null")) 0) "dead" "alive")) ) (format #t fmtstr db (conc host ":" port) pid age last-mod state) - (system (conc "rm " dbfile)) + (system (conc "rm " sfile)) ) ) sinfos ) ) @@ -2655,15 +2655,24 @@ (let ((res (dbmod:db-to-db-sync src-db dest-db last-update (dbfile:db-init-proc) keys))) (if res (debug:print-info 0 *default-log-port* "Synced " res " records from "src-db" to "dest-db) (debug:print-info 0 *default-log-port* "No sync due to permissions or other issue.")) res)))) - (start-time (current-seconds))) + (start-time (current-seconds)) + (synclock-mod-time (if (file-exists? lockfile) + (handle-exceptions + exn + #f + (file-modification-time synclock-file)) + #f)) + (age (if synclock-mod-time (- (current-seconds) synclock-mod-time) 1000)) + ) (if (and src-db dest-db) (if (file-exists? src-db) - (if (file-exists? lockfile) - (debug:print 0 *default-log-port* "Lock "lockfile" exists, skipping sync...") + (if (and (file-exists? lockfile) (< age 20)) + (debug:print 0 *default-log-port* "Lock "lockfile" exists, skipping sync...") + (begin (dbfile:with-simple-file-lock lockfile (lambda () (let loop ((last-changed (current-seconds)) (last-update 0)) @@ -2678,11 +2687,14 @@ (if (and sync-period sync-timeout) ;; (if (and (< (- now-time start-time) 600) ;; hard limit on how long we run for (> sync-timeout (- now-time last-changed))) (begin (if sync-period (thread-sleep! sync-period)) - (loop (if (> changes 0) now-time last-changed) now-time))))))))) + (loop (if (> changes 0) now-time last-changed) now-time)))))))) + (debug:print 0 *default-log-port* "Releasing lock file " lockfile) + ) + ) (debug:print 0 *default-log-port* "No sync due to unreadble or non-existant source file"src-db)) (debug:print 0 *default-log-port* "Usage for -db2db; -to and -from must be specified")) (set! *didsomething* #t))) (if (args:get-arg "-list-test-time")