Skip to content

Commit

Permalink
Fix skaffold pid fo macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny authored and zipofar committed Oct 25, 2023
1 parent b342e0a commit 3d59cab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ gem_uninstall:
gem uninstall uffizzi-cli

gem_reinstall:
rm uffizzi-cli-*.gem -f
ls -la | grep uffizzi-cli- | rm -f
make gem_uninstall
make gem_build_install

Expand Down
28 changes: 22 additions & 6 deletions lib/uffizzi/services/dev_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,29 @@ def dev_environment
Uffizzi::ConfigHelper.dev_environment
end

def find_skaffold_pid(ppid)
ppid_regex = /\w*\s+\d+\s+#{ppid}.*\sskaffold dev/
pid_regex = /\w*\s+(\d+)\s+#{ppid}.*\sskaffold dev/

def find_skaffold_pid(pid)
pid_regex = /\w*#{pid}.*skaffold dev/
io = Uffizzi.ui.popen('ps -ef')
ps = io.readlines.detect { |l| l.match?(ppid_regex) }
ps.match(pid_regex)[1]
processes = io.readlines.select { |l| l.match?(pid_regex) }

if processes.count.zero?
raise StandardError.new('Can\'t find skaffold process pid')
end

# HACK: For MacOS
if processes.count == 1
current_pid = processes[0].gsub(/\s+/, ' ').lstrip.split[1]
return pid if current_pid.to_s == pid.to_s

raise StandardError.new('Can\'t find skaffold process pid')
end

# HACK: For Linux
parent_process = processes.detect do |ps|
ps.gsub(/\s+/, ' ').lstrip.split[2].to_s == pid.to_s
end

parent_process[1]
end
end
end

0 comments on commit 3d59cab

Please sign in to comment.