File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed
Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,18 @@ tasks.add(services.healthcheck())
3434
3535local end_time = timeout and os.time () + timeout or nil
3636log_info (" ascend started" )
37- tasks .run ({ stopOnError = true , end_time = end_time })
37+ local stop_reason = tasks .run ({ stopOnError = true , end_time = end_time })
3838
3939tasks .clear ()
4040tasks .add (services .stop_all ())
4141tasks .run ({ ignoreStop = true , stopOnEmpty = true })
4242
4343log_info (" ascend stopped" )
44+
45+ if stop_reason == " error" then
46+ os.exit (1 )
47+ end
48+
49+ if stop_reason == " timeout" then
50+ os.exit (2 )
51+ end
Original file line number Diff line number Diff line change @@ -27,15 +27,25 @@ function tasks.add(task)
2727 table.insert (taskQueue , task )
2828end
2929
30+ --- @alias StopReason " error" | " empty" | " timeout" | " requested"
31+
3032--- run all tasks in the task queue
3133--- @param options TaskPoolOptions
34+ --- @return StopReason
3235function tasks .run (options )
3336 if not options then
3437 options = {}
3538 end
3639
37- while options .ignoreStop or not is_stop_requested () and not timed_out (options .end_time ) do
38- local stop = false
40+ while true do
41+ if not options .ignoreStop and is_stop_requested () then
42+ return " requested"
43+ end
44+ if timed_out (options .end_time ) then
45+ return " timeout"
46+ end
47+
48+ local error_occured = false
3949
4050 local newTaskQueue = {}
4151 for _ , task in ipairs (taskQueue ) do
@@ -46,7 +56,7 @@ function tasks.run(options)
4656 if not ok then
4757 log_error (" !!! task failed !!!" , { error = err })
4858 if options .stopOnError then
49- stop = true
59+ error_occured = true
5060 break
5161 end
5262 end
@@ -55,8 +65,11 @@ function tasks.run(options)
5565 end
5666
5767 taskQueue = newTaskQueue
58- if stop or (options .stopOnEmpty and # taskQueue == 0 ) then
59- break
68+ if error_occured then
69+ return " error"
70+ end
71+ if (options .stopOnEmpty and # taskQueue == 0 ) then
72+ return " empty"
6073 end
6174 os .sleep (100 , 1000 )
6275 end
Original file line number Diff line number Diff line change 1- local ASCEND_VERSION = " 0.7.3 "
1+ local ASCEND_VERSION = " 0.7.4 "
22
33return {
4- VERSION = ASCEND_VERSION ,
4+ VERSION = ASCEND_VERSION
55}
You can’t perform that action at this time.
0 commit comments