Module: Gisele::VM::Lifecycle

Included in:
Gisele::VM, Proxy::Client
Defined in:
lib/gisele/vm/lifecycle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_errorObject (readonly)

Returns the value of attribute last_error.



6
7
8
# File 'lib/gisele/vm/lifecycle.rb', line 6

def last_error
  @last_error
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/gisele/vm/lifecycle.rb', line 5

def status
  @status
end

Instance Method Details

#runObject

Raises:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gisele/vm/lifecycle.rb', line 24

def run
  raise InvalidStateError, "VM already running" unless stopped?
  if EM.reactor_running?
    starter
    EM.reactor_thread.join
  else
    EM.error_handler do |ex|
      fatal("EventMachine crashed: #{ex.message}\n" + ex.backtrace.join("\n"))
      if warmup?
        @status = :stopped
        EM.stop_event_loop
      end
    end
    EM::run &method(:starter)
  end
end

#running?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/gisele/vm/lifecycle.rb', line 12

def running?
  @status == :running
end

#shutdown?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/gisele/vm/lifecycle.rb', line 20

def shutdown?
  @status == :shutdown
end

#stopObject

Raises:



41
42
43
44
45
46
47
48
49
# File 'lib/gisele/vm/lifecycle.rb', line 41

def stop
  raise InvalidStateError, "VM not running" unless running?
  @status = :shutdown
  info('VM stop request received, disconnecting.')
  registry.disconnect
  EM.stop_event_loop
  @status = :stopped
  info('VM stopped successfully.')
end

#stopped?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/gisele/vm/lifecycle.rb', line 8

def stopped?
  @status == :stopped
end

#warmup?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/gisele/vm/lifecycle.rb', line 16

def warmup?
  @status == :warmup
end