From fda4aef9c711eca5dde23f4e963e68fcdca1bd13 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 25 Jul 2022 14:29:38 -0700 Subject: [PATCH] Make server instance accessible, return integer value --- plugins/commands/serve/command.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/commands/serve/command.rb b/plugins/commands/serve/command.rb index 5cdb9941c..19777e225 100644 --- a/plugins/commands/serve/command.rb +++ b/plugins/commands/serve/command.rb @@ -32,6 +32,7 @@ module VagrantPlugins class << self attr_accessor :broker + attr_accessor :server attr_reader :cache end @cache = Util::Cacher.new @@ -127,9 +128,12 @@ module VagrantPlugins STDOUT.puts "1|1|tcp|#{bind_addr}:#{port}|grpc" STDOUT.flush logger.info("Vagrant GRPC service is now running addr=#{bind_addr.inspect} port=#{port.inspect}") - s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT', 'SIGINT']) + VagrantPlugins::CommandServe.server = s + s.run_till_terminated_or_interrupted(['EXIT', 'HUP', 'INT', 'QUIT', 'ABRT']) + 0 ensure - logger.info("Vagrant GRPC service is shutting down") + VagrantPlugins::CommandServe.server = nil + logger.info("Vagrant GRPC service shut down") end end end