Commit a66789a4 authored by Marat Kalibekov's avatar Marat Kalibekov
Browse files

Merge branch 'pc-fix-error-500-on-git-processes' into 'master'

Fix error 500 when process file goes away in a race condition

Closes #16

See merge request !44
parents 501fed21 4f7c2611
Pipeline #45662 passed with stage
in 4 minutes and 28 seconds
......@@ -94,7 +94,11 @@ module GitLab
counts = Hash.new(0)
Utils.pgrep("^git ").each do |pid|
process_cmd = File.read("/proc/#{pid}/cmdline")
process_cmd = begin
File.read("/proc/#{pid}/cmdline")
rescue
"" # Process file is gone (race condition)
end
subcommand = self.class.extract_subcommand(process_cmd)
next unless subcommand # Unlikely, but just to be safe
......@@ -127,6 +131,7 @@ module GitLab
end
def self.extract_subcommand(cmd)
return if cmd.empty?
cmd_splitted = cmd.split("\u0000") # cmdline does not return it space-separated
cmd_splitted.shift # Because it's "git"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment