;;======================================================================
;; 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 stml2))
(declare (uses mtargs))
(declare (uses commonmod))
(declare (uses apimod))
(declare (uses keysmod))
(declare (uses dbmod))
(declare (uses ducttape-lib))
(declare (uses itemsmod))
(declare (uses mtconfigf))
(declare (uses odsmod))
(declare (uses pgdbmod))
(declare (uses pkts))
(declare (uses rmtmod))
(declare (uses mtmod))
(declare (uses servermod))
(declare (uses tasksmod))
(declare (uses testsmod))
(declare (uses subrunmod))
(declare (uses itemsmod))
(declare (uses runsmod))
;; (declare (uses archivemod))
;; (declare (uses clientmod))
;; (declare (uses dcommonmod))
;; (declare (uses envmod))
;; (declare (uses ezstepsmod))
;; (declare (uses ftail))
;; (declare (uses keysmod))
;; (declare (uses launchmod))
;; (declare (uses processmod))
;; (declare (uses runconfigmod))
;; (declare (uses subrunmod))
;; (declare (uses vgmod))
(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
tcp
typed-records
udp
uri-common
z3
)
(import (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 stml2)
(import (prefix mtargs args:))
;; Order here is important!
(import commonmod)
(import keysmod)
(import pgdbmod)
(import tasksmod)
(import dbmod)
(import apimod)
(import ducttape-lib)
(import itemsmod)
(import pkts)
(import rmtmod)
(import mtmod)
(import testsmod)
(import servermod)
(import subrunmod)
(import itemsmod)
(import runsmod)
;; (import archivemod)
;; (import clientmod)
;; (import dcommonmod)
;; (import envmod)
;; (import ezstepsmod)
;; (import ftail)
;; (import keysmod)
;; (import launchmod)
;; (import odsmod)
;; (import processmod)
;; (import runconfigmod)
;; (import subrunmod)
;; (import vgmod)
;; (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 *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 "archive-inc.scm")
(include "client-inc.scm")
(include "env-inc.scm")
(include "portlogger-inc.scm")
(include "process-inc.scm") ;; L6
(include "runconfig-inc.scm")
;; (include "api-inc.scm") ;; L3
;; (include "common-inc.scm") ;; L5
;; (include "db-inc.scm") ;; L4
;; (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 "rmt-inc.scm") ;; L2
;; (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