Class: ServerEngine::MultiThreadServer::WorkerMonitor

Inherits:
Object
  • Object
show all
Defined in:
lib/serverengine/multi_thread_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worker, thread) ⇒ WorkerMonitor

Returns a new instance of WorkerMonitor.



39
40
41
42
43
# File 'lib/serverengine/multi_thread_server.rb', line 39

def initialize(worker, thread)
  @worker = worker
  @thread = thread
  @restart_at = nil
end

Instance Attribute Details

#restart_atObject

Returns the value of attribute restart_at.



45
46
47
# File 'lib/serverengine/multi_thread_server.rb', line 45

def restart_at
  @restart_at
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/serverengine/multi_thread_server.rb', line 73

def alive?
  @thread.alive?
end

#joinObject



69
70
71
# File 'lib/serverengine/multi_thread_server.rb', line 69

def join
  @thread.join
end

#recoverable?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/serverengine/multi_thread_server.rb', line 77

def recoverable?
  true
end

#send_reloadObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/serverengine/multi_thread_server.rb', line 58

def send_reload
  Thread.new do
    begin
      @worker.reload
    rescue => e
      ServerEngine.dump_uncaught_error(e)
    end
  end
  nil
end

#send_stop(stop_graceful) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/serverengine/multi_thread_server.rb', line 47

def send_stop(stop_graceful)
  Thread.new do
    begin
      @worker.stop
    rescue => e
      ServerEngine.dump_uncaught_error(e)
    end
  end
  nil
end