Signed-off-by: Wu Fengguang wfg@mail.ustc.edu.cn --- src/extract-stats/constants.cr | 2 +- src/extract-stats/extract_stats.cr | 10 +++++----- src/monitoring/monitoring.cr | 1 + src/scheduler/jobfile_operate.cr | 21 +++++++++++---------- src/spec/scheduler/tools_spec.cr | 8 ++++---- 5 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/src/extract-stats/constants.cr b/src/extract-stats/constants.cr index 332962a..70c66ad 100644 --- a/src/extract-stats/constants.cr +++ b/src/extract-stats/constants.cr @@ -5,4 +5,4 @@ EXTRACT_STATS_QUEUE_PATH = "extract_stats" STATS_WORKER_COUNT = 10
DELIMITER_TASK_QUEUE = "delimiter" -ERROR_ID_FILES = %w(build-pkg.json) +ERROR_ID_FILES = %w[build-pkg.json] diff --git a/src/extract-stats/extract_stats.cr b/src/extract-stats/extract_stats.cr index d3f3203..45310ad 100644 --- a/src/extract-stats/extract_stats.cr +++ b/src/extract-stats/extract_stats.cr @@ -7,15 +7,15 @@ require "./stats_worker" module ExtractStats # Consume scheduler queue def self.in_extract_stats - self.back_fill_task + back_fill_task STATS_WORKER_COUNT.times do - Process.fork { - self.consume_task - } + Process.fork do + consume_task + end end
# keep main-process alive - sleep() + sleep end
def self.consume_task diff --git a/src/monitoring/monitoring.cr b/src/monitoring/monitoring.cr index 178e4c9..e665d5f 100644 --- a/src/monitoring/monitoring.cr +++ b/src/monitoring/monitoring.cr @@ -24,6 +24,7 @@ module Monitoring
socket.on_close do next unless query.as_h? + filter.remove_filter_rule(query, socket) end end diff --git a/src/scheduler/jobfile_operate.cr b/src/scheduler/jobfile_operate.cr index 0533346..e0e298f 100644 --- a/src/scheduler/jobfile_operate.cr +++ b/src/scheduler/jobfile_operate.cr @@ -15,7 +15,7 @@ end module Jobfile::Operate def self.prepare_dir(file_path : String) file_path_dir = File.dirname(file_path) - if !File.exists?(file_path_dir) + unless File.exists?(file_path_dir) FileUtils.mkdir_p(file_path_dir) end end @@ -59,11 +59,12 @@ module Jobfile::Operate if val.as_h? return false end - if val.as_a? - value = shell_escape(val.as_a) - else - value = shell_escape(val.to_s) - end + + value = if val.as_a? + shell_escape(val.as_a) + else + shell_escape(val.to_s) + end script_lines << "\texport #{key}=" + value if value end end @@ -78,7 +79,7 @@ module Jobfile::Operate script_lines << "\texport LKP_SRC=/lkp/${user:-lkp}/src" script_lines << "}\n\n"
- script_lines = "#{script_lines}" + script_lines = script_lines.to_s script_lines = JSON.parse(script_lines) end
@@ -121,7 +122,7 @@ module Jobfile::Operate
if job_sh_array.empty? lkp_src = prepare_lkp_tests(job_content["lkp_initrd_user"], - job_content["os_arch"]) + job_content["os_arch"])
cmd = "#{lkp_src}/sbin/create-job-cpio.sh #{temp_yaml}" idd = `#{cmd}` @@ -158,8 +159,8 @@ module Jobfile::Operate
# update lkp-xxx.cgz if they are different target_path = update_lkp_when_different(expand_dir_base, - lkp_initrd_user, - os_arch) + lkp_initrd_user, + os_arch)
# delete oldest lkp, if exists too much del_lkp_if_too_much(expand_dir_base) diff --git a/src/spec/scheduler/tools_spec.cr b/src/spec/scheduler/tools_spec.cr index 0a71af0..4c3a6aa 100644 --- a/src/spec/scheduler/tools_spec.cr +++ b/src/spec/scheduler/tools_spec.cr @@ -8,16 +8,16 @@ require "file_utils" describe Public do describe "hash replace" do it "can replace k:v" do - hash_old = {"name" => "OldValue"} - hash_new = {"name" => "NewValue"} + hash_old = { "name" => "OldValue" } + hash_new = { "name" => "NewValue" } hash_result = Public.hash_replace_with(hash_old, hash_new)
(hash_result["name"]).should eq("NewValue") end
it "can add k:v" do - hash_old = {"name2" => "OldValue"} - hash_new = {"name" => "NewValue"} + hash_old = { "name2" => "OldValue" } + hash_new = { "name" => "NewValue" } hash_result = Public.hash_replace_with(hash_old, hash_new)
(hash_result["name"]).should eq("NewValue")