Megatest

megamod.scm at [e429044746]
Login

File megamod.scm artifact 29d2df538a part of check-in e429044746


;;======================================================================
;; Copyright 2019, Matthew Welland.
;; 
;; This file is part of Megatest.
;; 
;;     Megatest is free software: you can redistribute it and/or modify
;;     it under the terms of the GNU General Public License as published by
;;     the Free Software Foundation, either version 3 of the License, or
;;     (at your option) any later version.
;; 
;;     Megatest is distributed in the hope that it will be useful,
;;     but WITHOUT ANY WARRANTY; without even the implied warranty of
;;     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;     GNU General Public License for more details.
;; 
;;     You should have received a copy of the GNU General Public License
;;     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.

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

(declare (unit megamod))
(declare (uses commonmod))
;; (declare (uses dbmod))
;; ;;(declare (uses apimod))
;; (declare (uses ftail))
;; ;; (declare (uses rmtmod))
;; (declare (uses apimod))
;; (declare (uses archivemod))
;; (declare (uses clientmod))
;; (declare (uses dbmod))
;; (declare (uses dcommonmod))
;; (declare (uses envmod))
;; (declare (uses ezstepsmod))
;; (declare (uses itemsmod))
;; (declare (uses keysmod))
;; (declare (uses launchmod))
;; (declare (uses odsmod))
;; (declare (uses processmod))
;; (declare (uses runconfigmod))
(declare (uses runsmod))
;; (declare (uses servermod))
;; (declare (uses subrunmod))
;; (declare (uses tasksmod))
;; (declare (uses testsmod))
;; (declare (uses vgmod))
(declare (uses pkts))

(module megamod
	*
	
(import scheme chicken data-structures extras)
(use 
 (prefix base64 base64:)
 (prefix dbi dbi:)
 (prefix nanomsg nmsg:)
 (prefix sqlite3 sqlite3:)
 call-with-environment-variables
 csv
 csv-xml
 data-structures
 directory-utils
 dot-locking
 extras
 files
 fmt
 format
 hostinfo
 http-client
 intarweb
 irregex
 matchable
 md5
 message-digest
 pathname-expand
 ;; pkts
 ports
 posix
 ;; queue
 regex
 regex-case
 s11n
 sparse-vectors
 spiffy
 spiffy-directory-listing
 spiffy-request-vars
 sql-de-lite
 srfi-1
 srfi-4
 srfi-13
 srfi-18
 srfi-69
 stack
 stml2
 tcp
 typed-records
 udp
 uri-common
 z3
 )

(use (prefix mtconfigf configf:))
(define read-config configf:read-config)
(define find-and-read-config configf:find-and-read-config)
(define config:eval-string-in-environment configf:eval-string-in-environment)

(import spiffy)

;; (import apimod)
;; (import archivemod)
;; (import clientmod)
(import commonmod)
;; (import dbmod)
;; (import dcommonmod)
;; (import envmod)
;; (import ezstepsmod)
;; (import ftail)
;; (import itemsmod)
;; (import keysmod)
;; (import launchmod)
;; (import odsmod)
;; (import processmod)
(import rmtmod)
;; (import runconfigmod)
(import runsmod)
;; (import servermod)
;; (import subrunmod)
;; (import tasksmod)
;; (import testsmod)
;; (import vgmod)
(import pkts)

(use (prefix ulex ulex:))

(include "common_records.scm")
(include "db_records.scm")
(include "key_records.scm")
(include "run_records.scm")
(include "task_records.scm")
(include "test_records.scm")
;; (include "vg_records.scm")

;;======================================================================
;; L O C K I N G   M E C H A N I S M S 
;;======================================================================

;; globals
(define *writes-total-delay* 0)
(define *exit-started* #f)
(define *last-monitor-update-time* 0)
(define *default-log-port* (current-error-port))

;; The watchdog is to keep an eye on things like db sync etc.
;;

;; TODO: for multiple areas, we will have multiple watchdogs; and multiple threads to manage
;; Moved watchdog back to megatest.scm
#;(define *watchdog* (make-thread
		    (lambda ()
		      (handle-exceptions
			  exn
			  (begin
			    (print-call-chain)
			    (print " message: " ((condition-property-accessor 'exn 'message) exn)))
			(common:watchdog)))
		    "Watchdog thread"))

(include "api-inc.scm")       ;; L3 
(include "archive-inc.scm")  
(include "client-inc.scm")
(include "common-inc.scm")    ;; L5
(include "db-inc.scm")        ;; L4
(include "env-inc.scm")
(include "http-transport-inc.scm")
(include "items-inc.scm")
(include "keys-inc.scm")
(include "launch-inc.scm")     ;; L1
(include "margs-inc.scm")
(include "mt-inc.scm")
(include "ods-inc.scm")        ;; L1
(include "pgdb-inc.scm")
(include "portlogger-inc.scm")
(include "process-inc.scm")    ;; L6
(include "rmt-inc.scm")        ;; L2
(include "runconfig-inc.scm")
(include "runs-inc.scm")       ;; L1.5
(include "server-inc.scm")
(include "subrun-inc.scm")
(include "tasks-inc.scm")
(include "tdb-inc.scm")
(include "tests-inc.scm")

;; (include "js-path.scm") ;; moved into init procedure in tests-inc.scm

)
;; http-transport:server-dat definition moved to common_records.scm
;; bunch of small functions factored out of send-receive to make debug easier