From 83dfe494e75713eadfc2a7b906acf30c6aa9c678 Mon Sep 17 00:00:00 2001 From: Victoria Jeffrey Date: Thu, 25 Aug 2016 12:37:25 -0400 Subject: [PATCH] move train connection out of loop for command_simulator --- tasks/command_simulator.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks/command_simulator.rb b/tasks/command_simulator.rb index 440bc871d..cd8838f0d 100644 --- a/tasks/command_simulator.rb +++ b/tasks/command_simulator.rb @@ -3,13 +3,13 @@ require 'train' commands = { 'inspec_exec' => 'inspec exec examples/profile/controls/example.rb', 'inspec_version' => 'inspec version' } +backend = Train.create('local') +conn = backend.connection + commands.each do |keyname, command| - backend = Train.create('local') - conn = backend.connection # loop around commands cmd = conn.run_command(command) cmd.stdout - conn.close # save the result and put it in inspec/www/app/results with the keyname as filename result = cmd.stdout @@ -18,3 +18,5 @@ commands.each do |keyname, command| out_file.puts(result) out_file.close end + +conn.close