Method: Facy::Core#start

Defined in:
lib/facy/core.rb

#start(options = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/facy/core.rb', line 66

def start(options={})
  _init      

  EM.run do
    Thread.start do
      while buf = Readline.readline(config[:prompt], true) 
        execute(buf.strip)
      end
    end

    Thread.start do
      EM.add_periodic_timer(config[:stream_fetch_interval]) do
        facebook_stream_fetch
      end
    end
    
    Thread.start do
      EM.add_periodic_timer(config[:output_interval]) do
        periodic_output 
      end
    end

    Thread.start do
      EM.add_periodic_timer(config[:notification_fetch_interval]) do
        facebook_notification_fetch
      end
    end

    Signal.trap("INT")  { stop_process }
    Signal.trap("TERM") { stop_process }
  end
end