Megatest

Diff
Login

Differences From Artifact [a2547ad8cd]:

To Artifact [21d5d83224]:


59
60
61
62
63
64
65
66
67
68



69
70
71

72
73

74
75
76
77
78
79
80
59
60
61
62
63
64
65



66
67
68
69
70

71
72

73
74
75
76
77
78
79
80







-
-
-
+
+
+


-
+

-
+







;; 	      (rpc-transport:launch run-id)))))

;;======================================================================
;; S E R V E R   U T I L I T I E S 
;;======================================================================

;; Get the transport
(define (server:get-transport)
  (if *transport-type*
      *transport-type*
(define (server:get-transport area-dat)
  (if (megatest:area-transport area-dat)
      (megatest-area-transport area-dat)
      (let ((ttype (string->symbol
		    (or (args:get-arg "-transport")
			(configf:lookup *configdat* "server" "transport")
			(configf:lookup (megatest:area-configdat area-dat) "server" "transport")
			"rpc"))))
	(set! *transport-type* ttype)
	(megatest:area-transport-set! area-dat ttype)
	ttype)))
	    
;; Generate a unique signature for this server
(define (server:mk-signature)
  (message-digest-string (md5-primitive) 
			 (with-output-to-string
			   (lambda ()
100
101
102
103
104
105
106
107
108




109
110

111
112

113
114

115
116
117
118
119

120
121
122
123
124
125
126
100
101
102
103
104
105
106


107
108
109
110
111

112
113

114
115

116
117
118
119
120

121
122
123
124
125
126
127
128







-
-
+
+
+
+

-
+

-
+

-
+




-
+







     (debug:print 0 "ERROR: unrecognised transport type: " *transport-type*)
     result)))

;; Given a run id start a server process    ### NOTE ### > file 2>&1 
;; if the run-id is zero and the target-host is set 
;; try running on that host
;;
(define  (server:run run-id)
  (let* ((curr-host   (get-host-name))
(define  (server:run run-id area-dat)
  (let* ((configdat   (megatest:area-configdat area-dat))
	 (toppath     (megatest:area-path      area-dat))
	 (curr-host   (get-host-name))
	 (curr-ip     (server:get-best-guess-address curr-host))
	 (target-host (configf:lookup *configdat* "server" "homehost" ))
	 (target-host (configf:lookup configdat "server" "homehost" ))
	 (testsuite   (common:get-testsuite-name))
	 (logfile     (conc *toppath* "/logs/" run-id ".log"))
	 (logfile     (conc toppath "/logs/" run-id ".log"))
	 (cmdln (conc (common:get-megatest-exe)
		      " -server " (or target-host "-") " -run-id " run-id (if (equal? (configf:lookup *configdat* "server" "daemonize") "yes")
		      " -server " (or target-host "-") " -run-id " run-id (if (equal? (configf:lookup configdat "server" "daemonize") "yes")
									      (conc " -daemonize -log " logfile)
									      "")
		      " -debug 4 testsuite:" testsuite))) ;; (conc " >> " logfile " 2>&1 &")))))
    (debug:print 0 "INFO: Starting server (" cmdln ") as none running ...")
    (push-directory *toppath*)
    (push-directory toppath)
    (if (not (directory-exists? "logs"))(create-directory "logs"))
    ;; host.domain.tld match host?
    (if (and target-host 
	     ;; look at target host, is it host.domain.tld or ip address and does it 
	     ;; match current ip or hostname
	     (not (string-match (conc "("curr-host "|" curr-host"\\..*)") target-host))
	     (not (equal? curr-ip target-host)))
239
240
241
242
243
244
245
246
247


248
249
250
251
252
253
254
255
241
242
243
244
245
246
247


248
249
250
251
252
253
254
255
256
257







-
-
+
+








	(begin
	  ;; (debug:print-info 2 "login successful")
	  #t)
	(begin
	  ;; (debug:print-info 2 "login failed")
	  #f))))

(define (server:get-timeout)
  (let ((tmo (configf:lookup  *configdat* "server" "timeout")))
(define (server:get-timeout area-dat)
  (let ((tmo (configf:lookup  (megatest:area-configdat area-dat) "server" "timeout")))
    (if (and (string? tmo)
	     (string->number tmo))
	(* 60 60 (string->number tmo))
	;; (* 3 24 60 60) ;; default to three days
	(* 60 1)         ;; default to one minute
	;; (* 60 60 25)      ;; default to 25 hours
	)))