diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-09 09:53:24 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-09 09:53:24 +0000 |
commit | cf76776d03885c02b58df07dbca42bc455f4a841 (patch) | |
tree | 9a69192ea7604268c596cafd7b4f8e93608483d7 /app | |
parent | 796bdf1dcb86b5e77fc054208afc632f75518605 (diff) | |
parent | 76c7b83dd5e345583fbaa26d9462a1bec7107a60 (diff) | |
download | gitlab-ce-cf76776d03885c02b58df07dbca42bc455f4a841.tar.gz |
Merge branch 'sidekiq-ps-parsing' into 'master'
* Moves splitting of `ps` result to helper.
* Users a regexp to extract the different parts
The result of `ps` at least depends on the _LANG_ and the distance of
_start_ to _now_ (start time then the day + hour then month+day)
I've tested with _LANG=en_US.UTF-8_ and _LANG=de_CH.UTF-8_
Closes #20632
See merge request !6245
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/sidekiq_helper.rb | 19 | ||||
-rw-r--r-- | app/views/admin/background_jobs/show.html.haml | 8 |
2 files changed, 21 insertions, 6 deletions
diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb new file mode 100644 index 00000000000..d440edc55ba --- /dev/null +++ b/app/helpers/sidekiq_helper.rb @@ -0,0 +1,19 @@ +module SidekiqHelper + SIDEKIQ_PS_REGEXP = /\A + (?<pid>\d+)\s+ + (?<cpu>[\d\.,]+)\s+ + (?<mem>[\d\.,]+)\s+ + (?<state>[DRSTWXZNLsl\+<]+)\s+ + (?<start>.+)\s+ + (?<command>sidekiq.*\])\s+ + \z/x + + def parse_sidekiq_ps(line) + match = line.match(SIDEKIQ_PS_REGEXP) + if match + match[1..6] + else + %w[? ? ? ? ? ?] + end + end +end diff --git a/app/views/admin/background_jobs/show.html.haml b/app/views/admin/background_jobs/show.html.haml index 4f680b507c4..05855db963a 100644 --- a/app/views/admin/background_jobs/show.html.haml +++ b/app/views/admin/background_jobs/show.html.haml @@ -28,14 +28,10 @@ %th COMMAND %tbody - @sidekiq_processes.each do |process| - - next unless process.match(/(sidekiq \d+\.\d+\.\d+.+$)/) - - data = process.strip.split(' ') %tr %td= gitlab_config.user - - 5.times do - %td= data.shift - %td= data.join(' ') - + - parse_sidekiq_ps(process).each do |value| + %td= value .clearfix %p %i.fa.fa-exclamation-circle |