-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.rb
51 lines (38 loc) · 977 Bytes
/
run.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env ruby
require_relative 'botconfig'
ignore_schedule = ARGV.include?"--ignore-schedule"
if ignore_schedule
IGNORE_SCHEDULE = true
puts "Will ignore schedule."
elsif !should_it_be_on()
puts 'Bot process started outside schedule. Halting'
puts 'If you are just testing the bot use "ruby run.rb --ignore-schedule"'
exit
end
require_relative 'bots'
require 'twitter_ebooks'
# Taken from twitter-ebooks : Temporary measure while migrating to twitter-ebooks 3.0
#require 'ostruct'
#require 'fileutils'
bots = Ebooks::Bot.all
threads = []
bots.each do |bot|
threads << Thread.new { bot.prepare }
end
threads.each(&:join)
threads = []
bots.each do |bot|
threads << Thread.new do
loop do
begin
bot.start
rescue Exception => e
bot.log e.inspect
puts e.backtrace.map { |s| "\t"+s }.join("\n")
end
bot.log "Sleeping before reconnect"
sleep 60
end
end
end
threads.each(&:join)