Close SSH session before exiting
This commit is contained in:
parent
9359f2e595
commit
336003d2d7
@ -54,6 +54,7 @@ module Producer
|
|||||||
|
|
||||||
def run
|
def run
|
||||||
worker.process load_recipe.tasks
|
worker.process load_recipe.tasks
|
||||||
|
env.cleanup
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_recipe
|
def load_recipe
|
||||||
|
@ -44,6 +44,10 @@ module Producer
|
|||||||
def dry_run?
|
def dry_run?
|
||||||
@dry_run
|
@dry_run
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cleanup
|
||||||
|
remote.cleanup
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,7 @@ module Producer
|
|||||||
module Core
|
module Core
|
||||||
class Remote
|
class Remote
|
||||||
attr_reader :hostname
|
attr_reader :hostname
|
||||||
|
attr_writer :session
|
||||||
|
|
||||||
def initialize(hostname)
|
def initialize(hostname)
|
||||||
@hostname = hostname
|
@hostname = hostname
|
||||||
@ -43,6 +44,10 @@ module Producer
|
|||||||
def environment
|
def environment
|
||||||
Environment.new_from_string(execute 'env')
|
Environment.new_from_string(execute 'env')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cleanup
|
||||||
|
session.close if @session
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -172,6 +172,11 @@ module Producer::Core
|
|||||||
.with([an_instance_of(Task), an_instance_of(Task)])
|
.with([an_instance_of(Task), an_instance_of(Task)])
|
||||||
cli.run
|
cli.run
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'cleans up the env' do
|
||||||
|
expect(cli.env).to receive :cleanup
|
||||||
|
cli.run
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#load_recipe' do
|
describe '#load_recipe' do
|
||||||
|
@ -157,5 +157,12 @@ module Producer::Core
|
|||||||
expect(env).to be_dry_run
|
expect(env).to be_dry_run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#cleanup' do
|
||||||
|
it 'cleans up the remote' do
|
||||||
|
expect(env.remote).to receive :cleanup
|
||||||
|
env.cleanup
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -136,5 +136,14 @@ module Producer::Core
|
|||||||
expect(remote.environment['FOO']).to eq 'bar'
|
expect(remote.environment['FOO']).to eq 'bar'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#cleanup' do
|
||||||
|
before { remote.session = double 'session' }
|
||||||
|
|
||||||
|
it 'closes the session' do
|
||||||
|
expect(remote.session).to receive :close
|
||||||
|
remote.cleanup
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user