Class: Istox::GrufListenerHook

Inherits:
Gruf::Hooks::Base
  • Object
show all
Defined in:
lib/istox/helpers/gruf_listener_hook.rb

Instance Method Summary collapse

Instance Method Details

#after_server_stop(server:) ⇒ Object



16
17
18
19
# File 'lib/istox/helpers/gruf_listener_hook.rb', line 16

def after_server_stop(server:)
    # do my thing after the server stops
    @listener.stop
end

#before_server_start(server:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/istox/helpers/gruf_listener_hook.rb', line 3

def before_server_start(server:)
    # do my thing before the server starts  

    @listener = ::Listen.to('app/rpc') do |modified, added, removed|
        puts "modified absolute path: #{modified}"
        puts "added absolute path: #{added}"
        puts "removed absolute path: #{removed}"
        
        server.init_restart
    end
    @listener.start # not blocking
end