Class: Proxy::RemoteExecution::Ssh::Dispatcher
- Inherits:
-
Dynflow::Actor
- Object
- Dynflow::Actor
- Proxy::RemoteExecution::Ssh::Dispatcher
- Defined in:
- lib/smart_proxy_remote_execution_ssh_core/dispatcher.rb
Overview
Service that handles running external commands for Actions::Command Dynflow action. It runs just one (actor) thread for all the commands running in the system and updates the Dynflow actions periodically.
Defined Under Namespace
Classes: Command
Instance Method Summary collapse
- #finish_command(command) ⇒ Object
-
#initialize(options = {}) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #initialize_command(command) ⇒ Object
- #kill(command) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Dispatcher
Returns a new instance of Dispatcher.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/smart_proxy_remote_execution_ssh_core/dispatcher.rb', line 34 def initialize( = {}) @clock = [:clock] || Dynflow::Clock.spawn('proxy-dispatcher-clock') @logger = [:logger] || Logger.new($stderr) @session_args = { :logger => @logger, :clock => @clock, :connector_class => [:connector_class] || Connector, :local_working_dir => [:local_working_dir] || Settings.instance.local_working_dir, :remote_working_dir => [:remote_working_dir] || Settings.instance.remote_working_dir, :client_private_key_file => Settings.instance.ssh_identity_key_file, :refresh_interval => [:refresh_interval] || 1 } @sessions = {} end |
Instance Method Details
#finish_command(command) ⇒ Object
64 65 66 67 68 |
# File 'lib/smart_proxy_remote_execution_ssh_core/dispatcher.rb', line 64 def finish_command(command) close_session(command) rescue => exception handle_command_exception(command, exception) end |
#initialize_command(command) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/smart_proxy_remote_execution_ssh_core/dispatcher.rb', line 49 def initialize_command(command) @logger.debug("initalizing command [#{command}]") open_session(command) rescue => exception handle_command_exception(command, exception) end |
#kill(command) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/smart_proxy_remote_execution_ssh_core/dispatcher.rb', line 56 def kill(command) @logger.debug("killing command [#{command}]") session = @sessions[command.id] session.tell(:kill) if session rescue => exception handle_command_exception(command, exception, false) end |