Skip to content

Commit

Permalink
Add spinner to automatically restart a downed bot
Browse files Browse the repository at this point in the history
  • Loading branch information
feldpost committed Mar 26, 2009
1 parent 07103e0 commit ab79507
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions spinner.rb
@@ -0,0 +1,44 @@
class Spinner

def self.run!
spinner = new
spinner.run!
end

def run!
start unless running?
end

def running?
!status.match(/Bot is NOT running/)
end

def pid
status.match(/Bot is running \((\d+?)\)/)[1].to_i rescue nil
end

def status
run :status
end

def start
run :start
end

def stop
run :stop
end

protected

def run(action)
`ruby #{bot} #{action}`
end

def bot
File.join(Dir.pwd,'bot.rb')
end

end

Spinner.run!

0 comments on commit ab79507

Please sign in to comment.