Megatest

Diff
Login

Differences From Artifact [724c5d0f96]:

To Artifact [4ba3510aa8]:


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
142
143
144
145
146
147
148

149
150
151
152
153
154
155







-







;;
;; NOTE: organise by dbfname, not run-id so we don't need
;;       to pull in more modules
;;
(define (tt:start-server areapath dbfname handler)
  ;; is there already a server for this dbfile? Then exit.
  (let* ((ttdat  (make-tt-srv areapath: areapath))
	 ;; (dbfname (dbmod:run-id->dbfname run-id))
	 (servers (tt:find-server ttdat dbfname)))
    (tt-srv-handler-set! ttdat handler)
    (if (null? servers)
	(begin
	  (tt:start-tcp-server ttdat) ;; start the tcp-server which applies handler to incoming data
	  (tt:keep-running ttdat dbfname))
	(begin
235
236
237
238
239
240
241
242

243
244
245
246
247
248
249
234
235
236
237
238
239
240

241
242
243
244
245
246
247
248







-
+







	   (servinf (conc servdir"/"host":"port"-"(current-process-id)":"dbfname))
	   (serv-id (tt:mk-signature areapath))
	   (clean-proc (lambda ()
			 (delete-file* servinf))))
      (tt-srv-cleanup-proc-set! ttdat clean-proc)
      (with-output-to-file servinf
	(lambda ()
	  (print "SERVER STARTED: "host":"port" AT "(current-seconds)" server-id: "serv-id" pid: "(current-process-id))))
	  (print "SERVER STARTED: "host":"port" AT "(current-seconds)" server-id: "serv-id" pid: "(current-process-id)" dbfname: "dbfname)))
      serv-id)))

;; find valid server
;; get servers listed, last part of name must match :<dbfname>
;; if more than one, wait one second and look again
;; future: ping oldest, if alive remove other :<dbfname> files
;;