Class: SimpleWorker::SshWorker
- Inherits:
-
AbstractListener
- Object
- AbstractListener
- SimpleWorker::SshWorker
- Defined in:
- lib/simpleworker/ssh_worker.rb
Overview
SshWorker.new(opts)
where ‘opts’ is a Hash of options:
:user => String name of user on remote host (default: `whoami`)
:host => String name of remote host (default: `hostname`)
:port => String port to connect on the remote host (default: 22)
:cmd => String bash string to execute on the remote host in the users login shell, in the remote 'dirname', and with the JOBID environment variable set to the current jobid, (default: `bundle install; rake;`)
:dirname => String remote directory in the users home directory (default: dynamic jobid)
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#dirname ⇒ Object
readonly
Returns the value of attribute dirname.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ SshWorker
constructor
A new instance of SshWorker.
-
#on_start(jobid) ⇒ Object
Destructive rsync to remote and start a process in the background on the remote server.
-
#on_stop ⇒ Object
Rsync from remote.
Methods inherited from AbstractListener
#on_interrupted, #on_log, #on_node_start, #on_node_stop, #on_task_active, #on_task_expire, #on_task_start, #on_task_stop, #on_timeout, #update
Constructor Details
#initialize(opts = {}) ⇒ SshWorker
Returns a new instance of SshWorker.
18 19 20 21 22 23 24 |
# File 'lib/simpleworker/ssh_worker.rb', line 18 def initialize(opts = {}) @user = opts[:user] || `whoami`.strip @host = opts[:host] || `hostname`.strip @port = opts[:port] || '22' @cmd = opts[:cmd] || 'bundle install; rake;' @dirname = opts[:dirname] end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
16 17 18 |
# File 'lib/simpleworker/ssh_worker.rb', line 16 def cmd @cmd end |
#dirname ⇒ Object (readonly)
Returns the value of attribute dirname.
16 17 18 |
# File 'lib/simpleworker/ssh_worker.rb', line 16 def dirname @dirname end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
16 17 18 |
# File 'lib/simpleworker/ssh_worker.rb', line 16 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
16 17 18 |
# File 'lib/simpleworker/ssh_worker.rb', line 16 def port @port end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
16 17 18 |
# File 'lib/simpleworker/ssh_worker.rb', line 16 def user @user end |
Instance Method Details
#on_start(jobid) ⇒ Object
Destructive rsync to remote and start a process in the background on the remote server.
27 28 29 30 31 32 33 |
# File 'lib/simpleworker/ssh_worker.rb', line 27 def on_start(jobid) @dirname ||= jobid @jobid = jobid sync_to_remote async_cmd end |
#on_stop ⇒ Object
Rsync from remote.
36 37 38 |
# File 'lib/simpleworker/ssh_worker.rb', line 36 def on_stop sync_from_remote end |