Class: Clacks::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/clacks/service.rb

Constant Summary collapse

WATCHDOG_SLEEP =

In practice timeouts occur when there is no activity keeping an IMAP connection open. Timeouts occuring are:

IMAP server timeout: typically after 30 minutes with no activity.
NAT Gateway timeout: typically after 15 minutes with an idle connection.

The solution to this is for the IMAP client to issue a NOOP (No Operation) command at intervals, typically every 29 minutes. We choose default 10 minutes.

ENV['CLACKS_WATCHDOG_SLEEP'] || 10 * 60

Instance Method Summary collapse

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/clacks/service.rb', line 16

def run
  begin
    Clacks.logger.info "Clacks v#{Clacks::VERSION} started"
    if Clacks.config[:pop3]
      run_pop3
    elsif Clacks.config[:imap]
      run_imap
    else
      raise "Either a POP3 or an IMAP server must be configured"
    end
  rescue Exception => e
    fatal(e)
  end
end

#stopObject



31
32
33
34
# File 'lib/clacks/service.rb', line 31

def stop
  $STOPPING = true
  exit unless finding?
end