Created
October 2, 2018 12:14
-
-
Save charger/2c9212ac603359ad4d3b71d5ec98f2a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/spec/support/the_service.rb | |
class TheServiceControl | |
#.... | |
def start | |
return unless @pid.nil? | |
puts "TheService starting. " | |
env = config['rails']['env'] | |
cmd = "go run #{config['rails']['main_go']} --config.file=#{config_path}" | |
puts cmd #useful for debug when need run project manually | |
#compile and run | |
Dir.chdir(File.dirname(config['rails']['main_go'])) { | |
@pid = Process.spawn(env, cmd, pgroup: true) | |
} | |
#wait until it ready to accept connections | |
VCR.configure { |c| c.allow_http_connections_when_no_cassette = true } | |
1.upto(10) do | |
response = HTTParty.get("http://#{host}/monitor") rescue nil | |
break if response.try(:code) == 200 | |
sleep(1) | |
end | |
VCR.configure { |c| c.allow_http_connections_when_no_cassette = false } | |
puts "TheService started. PID: #{@pid}" | |
end | |
#.... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment