Skip to content

Commit

Permalink
feat(gapic-ruby-generator): add logic to stop background process from…
Browse files Browse the repository at this point in the history
… toys gen on SIGINT
  • Loading branch information
aandreassa committed Jan 23, 2024
1 parent 9d7f5b5 commit c727248
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .toys/.toys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ def run
include :exec, e: true
include :terminal

Signal.trap("SIGINT") do
puts "SIGINT received. Cleaning up processes."
toys_gen_pids = `ps aux`.each_line.filter_map { |line| line.split[1].to_i if line.match?(/ruby.*protoc/)}
puts "No toys gen processes running." if toys_gen_pids.empty?
toys_gen_pids.each do |pid|
puts "Terminating pid #{pid}"
Process.kill("TERM", pid)
end
exit
end

def run
Dir.chdir "#{context_directory}/shared" do
cmd = ["gen"] + services + verbosity_flags
Expand Down

0 comments on commit c727248

Please sign in to comment.