121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
+
|
(define (tasks:num-in-available-state mdb run-id)
(let ((res 0))
(sqlite3:for-each-row
(lambda (num-in-queue)
(set! res num-in-queue))
mdb
"SELECT count(id) FROM servers WHERE run_id=?;"
"SELECT count(id) FROM servers WHERE run_id=? AND state = 'available';"
run-id)
res))
(define (tasks:server-clean-out-old-records-for-run-id mdb run-id)
(sqlite3:execute mdb "DELETE FROM servers WHERE state in ('available','shutting-down') AND (strftime('%s','now') - start_time) > 30 AND run_id=?;" run-id))
(define (tasks:server-force-clean-running-records-for-run-id mdb run-id)
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
-
+
|
(let* ((header (list "id" "hostname" "pid" "interface" "port" "pubport" "state" "run_id" "priority" "start_time"))
(selstr (string-intersperse header ","))
(res '()))
(sqlite3:for-each-row
(lambda (a . b)
(set! res (cons (apply vector a b) res)))
mdb
(conc "SELECT " selstr " FROM servers WHERE run_id=? ORDER BY start_time DESC;")
(conc "SELECT " selstr " FROM servers WHERE run_id=? AND state in ('available','running') ORDER BY start_time DESC;")
run-id)
(vector header res)))
(define (tasks:get-server mdb run-id)
(let ((res #f)
(best #f))
(sqlite3:for-each-row
|