Module: Citrus::Master::Starter

Includes:
Utils
Included in:
Master
Defined in:
lib/citrus/master/starter.rb

Overview

Starter

Instance Method Summary collapse

Methods included from Utils

#local?

Instance Method Details

#local_run(cmd, host, options) ⇒ Object



54
55
56
# File 'lib/citrus/master/starter.rb', line 54

def local_run cmd, host, options
  spawn_process cmd, host, options
end

#run_server(server, &block) ⇒ Object

Run server

Parameters:

  • server (Hash)


32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/citrus/master/starter.rb', line 32

def run_server server, &block
  if local? server[:host]
    options = []
    options << sprintf('%s', $0)
    options << sprintf('env=%s', @app.env)
    server.each { |key, value|
      options << sprintf('%s=%s', key, value)
    }
    local_run 'ruby', nil, options
  else
  end
end

#run_serversObject

Run servers



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/citrus/master/starter.rb', line 17

def run_servers
  condition = @app.start_id || @app.type
  case condition
  when :master
  when :all
    @app.servers_map.each { |server_id, server|
      run_server server
    }
  else
  end
end

#spawn_process(cmd, host, options) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/citrus/master/starter.rb', line 61

def spawn_process cmd, host, options
  child = fork {
    exec cmd + options.inject('') { |res, str| res += ' ' + str }
  }
  EM.watch_process child, Module.new {
    define_method(:process_exited) {
      Process.wait child
    }
  }
end

#ssh_runObject



48
49
# File 'lib/citrus/master/starter.rb', line 48

def ssh_run
end