Skip to content

Commit 737797d

Browse files
committed
Attempt at restarting dead teams.
1 parent 749006a commit 737797d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

slack-api-explorer/app.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
11
module SlackApiExplorer
22
class App < SlackRubyBotServer::App
3+
include Celluloid
4+
35
def prepare!
46
super
57
purge_inactive_teams!
68
end
79

10+
def after_start!
11+
every 60 * 60 do
12+
ping_teams!
13+
end
14+
end
15+
816
private
917

1018
def purge_inactive_teams!
1119
Team.purge!
1220
end
21+
22+
def ping_teams!
23+
Team.active.each do |team|
24+
begin
25+
ping = team.ping!
26+
next if ping[:presence].online
27+
logger.warn "DOWN: #{team}"
28+
after 60 do
29+
ping = team.ping!
30+
unless ping[:presence].online
31+
logger.info "RESTART: #{team}"
32+
SlackApiExplorer::Service.instance.start!(team)
33+
end
34+
end
35+
rescue StandardError => e
36+
logger.warn "Error pinging team #{team}, #{e.message}."
37+
end
38+
end
39+
end
1340
end
1441
end

0 commit comments

Comments
 (0)