88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
db
(lambda ()
;; execution time is updated with every snag, wait 10 secs before doing anything with the queue
(sqlite3:for-each-row
(lambda (id . rem)
(set! res (apply vector id rem)))
db
"SELECT id,action,owner,state,target,name,test,item,creation_time,execution_time
FROM tasks_queue
WHERE
state='new' OR
(state='waiting' AND execution_time+10 > strftime('%s','now')) OR
state='reset'
ORDER BY state ASC LIMIT 1;")
(if res ;; yep, have work to be done
(begin
(sqlite3:execute db "UPDATE tasks_queue SET state='inprogress',execution_time=strftime('%s','now') WHERE id=?;"
(tasks:task-get-id res))
res)
#f)))))
|
|
|
|
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
db
(lambda ()
;; execution time is updated with every snag, wait 10 secs before doing anything with the queue
(sqlite3:for-each-row
(lambda (id . rem)
(set! res (apply vector id rem)))
db
"SELECT id,action,owner,state,target,name,test,item,creation_time,execution_time
FROM tasks_queue
WHERE
state='new' OR
(state='waiting' AND (strftime('%s','now')-execution_time) > 10) OR
state='reset'
ORDER BY execution_time ASC LIMIT 1;")
(if res ;; yep, have work to be done
(begin
(sqlite3:execute db "UPDATE tasks_queue SET state='inprogress',execution_time=strftime('%s','now') WHERE id=?;"
(tasks:task-get-id res))
res)
#f)))))
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
(tasks:monitors-update db)
(loop (+ count 1)(+ (current-seconds) 240)))
(loop (+ count 1) next-touch)))))))
(define (tasks:process-queue db megatestdbpath)
(let* ((task (tasks:snag-a-task db))
(action (if task (tasks:task-get-action task) #f)))
(if action
(case (string->symbol action)
((run) (tasks:start-run db task))
((remove) (tasks:remove-runs db task))
((lock) (tasks:lock-runs db task))
;; ((monitor) (tasks:start-monitor db task))
((rollup) (tasks:rollup-runs db task))
|
>
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
(tasks:monitors-update db)
(loop (+ count 1)(+ (current-seconds) 240)))
(loop (+ count 1) next-touch)))))))
(define (tasks:process-queue db megatestdbpath)
(let* ((task (tasks:snag-a-task db))
(action (if task (tasks:task-get-action task) #f)))
(print "tasks:process-queue task: " task)
(if action
(case (string->symbol action)
((run) (tasks:start-run db task))
((remove) (tasks:remove-runs db task))
((lock) (tasks:lock-runs db task))
;; ((monitor) (tasks:start-monitor db task))
((rollup) (tasks:rollup-runs db task))
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
(define (tasks:set-state db task-id state)
(sqlite3:execute db "UPDATE tasks_queue SET state=? WHERE id=?;"
state
task-id))
(define (tasks:start-run db task)
;; Starting run #(3 run matt reset ubuntu/afs/tmp ww44 % % 1319368208.0 1319386680.0)
;; Starting run #(5 run matt reset centos/nfs/nada ww42 all all 1319371306.0 1319386801.0)
(print "Starting run " task)
;; sillyness, just call the damn routine with the task vector and be done with it. FIXME SOMEDAY
(runs:run-tests db
(tasks:task-get-target task)
(tasks:task-get-name task)
(tasks:task-get-test task)
(tasks:task-get-item task)
(tasks:task-get-owner task)
(make-hash-table))
(tasks:set-state db (tasks:task-get-id task) "waiting")
)
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
(define (tasks:set-state db task-id state)
(sqlite3:execute db "UPDATE tasks_queue SET state=? WHERE id=?;"
state
task-id))
(define (tasks:start-run db task)
(let ((flags (make-hash-table)))
(hash-table-set! flags "-rerun" "NOT_STARTED")
(print "Starting run " task)
;; sillyness, just call the damn routine with the task vector and be done with it. FIXME SOMEDAY
(runs:run-tests db
(tasks:task-get-target task)
(tasks:task-get-name task)
(tasks:task-get-test task)
(tasks:task-get-item task)
(tasks:task-get-owner task)
flags)
(tasks:set-state db (tasks:task-get-id task) "waiting")))
|