Megatest

Check-in [42bfe6fba7]
Login
Overview
Comment:Basic auto server start working
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.70-nohomehost
Files: files | file ages | folders
SHA1: 42bfe6fba7c67860ddf9b40274faf84cc44777dd
User & Date: matt on 2022-11-21 07:14:33
Other Links: branch diff | manifest | tags
Context
2022-11-21
22:20
Server usage in dashboard mostly working check-in: 3ce83ed77c user: matt tags: v1.70-nohomehost
07:14
Basic auto server start working check-in: 42bfe6fba7 user: matt tags: v1.70-nohomehost
07:14
Makefile fixed check-in: 4c8c2cf803 user: matt tags: v1.70-nohomehost
Changes

Modified common.scm from [c81106d159] to [5559976353].

314
315
316
317
318
319
320
321
322




323
324
325
326
327
328
329
314
315
316
317
318
319
320


321
322
323
324
325
326
327
328
329
330
331







-
-
+
+
+
+







    ((skip) "SKIP")
    (else "FAIL")))

(define (common:logpro-exit-code->test-status exit-code)
  (status-sym->string (common:logpro-exit-code->status-sym exit-code)))

(defstruct remote
  (hh-dat            (or (server:choose-server *toppath* 'homehost)
			 (cons #f #f)))
  (hh-dat            (let ((res (or (server:choose-server *toppath* 'homehost)
				    (cons #f #f))))
		       (assert (pair? res)(conc "FATAL: hh-dat should be a pair, got "res))
		       res))
  (server-url        #f) ;; (server:check-if-running *toppath*) #f))
  (server-id         #f)
  (server-info       (if *toppath* (server:check-if-running *toppath*) #f))
  (last-server-check 0)  ;; last time we checked to see if the server was alive
  (connect-time      (current-seconds))
  (conndat           #f)
  (transport         *transport-type*)

Modified rmt.scm from [ad81bdd667] to [f32646f514].

50
51
52
53
54
55
56









57
58
59
60
61
62
63
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72







+
+
+
+
+
+
+
+
+







			(remote-conndat runremote)
			#f)))
	  (if cinfo
	      cinfo
	      (if (server:check-if-running areapath)
		  (client:setup areapath)
		  #f))))

(define (rmt:on-homehost? runremote)
  (let* ((hh-dat (remote-hh-dat runremote)))
    (if (pair? hh-dat)
	(cdr hh-dat)
	(begin
	  (debug:print-info 0 *default-log-port* "hh-dat="hh-dat)
	  #f))))


;;======================================================================

(define *send-receive-mutex* (make-mutex)) ;; should have separate mutex per run-id

;; RA => e.g. usage (rmt:send-receive 'get-var #f (list varname))
;;
175
176
177
178
179
180
181
182

183
184
185
186
187
188
189
184
185
186
187
188
189
190

191
192
193
194
195
196
197
198







-
+







     
     ;;DOT CASE5 [label="local\nread"];
     ;;DOT MUTEXLOCK -> CASE5 [label="server not required,\non homehost,\nread-only query"]; {rank=same "case 5" CASE5};
     ;;DOT CASE5 -> "rmt:open-qry-close-locally";

     ;; on homehost and this is a read
     ((and (not (remote-force-server runremote)) ;; honor forced use of server, i.e. server NOT required
	   (cdr (remote-hh-dat runremote))       ;; on homehost
	   (rmt:on-homehost? runremote)
           (member cmd api:read-only-queries))   ;; this is a read
      (mutex-unlock! *rmt-mutex*)
      (debug:print-info 12 *default-log-port* "rmt:send-receive, case  5")
      (rmt:open-qry-close-locally cmd 0 params))

     ;;DOT CASE6 [label="init\nremote"];
     ;;DOT MUTEXLOCK -> CASE6 [label="on homehost,\nwrite query,\nhave server,\ncan't reach it"]; {rank=same "case 6" CASE6};

Modified server.scm from [dc052c2093] to [64c69c7a6f].

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432












433
434
435
436
437
438
439
416
417
418
419
420
421
422










423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441







-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+







		 (thread-sleep! ( + 1 idletime))
		 (server:wait-for-server-start-last-flag areapath)))))))

;; oldest server alive determines host then choose random of youngest
;; five servers on that host
;;
(define (server:get-servers-info areapath)
  (let* ((servinfodir (conc *toppath*"/.servinfo"))
	 (allfiles    (glob (conc servinfodir"/*")))
	 (res         (make-hash-table)))
    (for-each
     (lambda (f)
       (let* ((hostport  (pathname-strip-directory f))
	      (serverdat (server:logf-get-start-info f)))
	 (hash-table-set! res hostport serverdat)))
     allfiles)
    res))
  (let* ((servinfodir (conc *toppath*"/.servinfo")))
    (if (not (file-exists? servinfodir))
	(create-directory servinfodir))
    (let* ((allfiles    (glob (conc servinfodir"/*")))
	   (res         (make-hash-table)))
      (for-each
       (lambda (f)
	 (let* ((hostport  (pathname-strip-directory f))
		(serverdat (server:logf-get-start-info f)))
	   (hash-table-set! res hostport serverdat)))
       allfiles)
      res)))

;; oldest server alive determines host then choose random of youngest
;; five servers on that host
;;
;; mode:
;;   best - get best server (random of newest five)
;;   home - get home host based on oldest server
489
490
491
492
493
494
495


496

497
498
499
500
501
502
503
491
492
493
494
495
496
497
498
499

500
501
502
503
504
505
506
507







+
+
-
+







			  
	    (else
	     (debug:print 0 *default-log-port* "ERROR: invalid command "mode)
	     #f)))
	(begin
	  (server:run areapath)
	  (thread-sleep! 3)
	  (case mode
	    ((homehost) (cons #f #f))
	  #f))))
	    (else	#f))))))

	  
;; kind start up of server, wait before allowing another server for a given
;; area to be launched
;;
(define (server:kind-run areapath)
  ;; look for $MT_RUN_AREA_HOME/logs/server-start-last