Class: Flowhook::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/flowhook/worker.rb

Overview

The worker to sending webhook

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Worker

Returns a new instance of Worker.



6
7
8
9
10
11
# File 'lib/flowhook/worker.rb', line 6

def initialize(options)
  @options = options
  @pidfile = File.expand_path('flowhook.pid')

  initialize_stream
end

Instance Method Details

#daemonize?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/flowhook/worker.rb', line 25

def daemonize?
  @options.daemonize
end

#pidfile?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/flowhook/worker.rb', line 29

def pidfile?
  !@pidfile.nil?
end

#startObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flowhook/worker.rb', line 13

def start
  check_pid
  daemonize if daemonize?
  write_pid
  trap_signals

  @stream.read do |event|
    # TODO: Logging response
    Thread.new { send event }
  end
end