File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 11module 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
1441end
You can’t perform that action at this time.
0 commit comments