Guest User

Untitled

a guest
Apr 23rd, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. require 'sinatra'
  2. require 'active_record'
  3.  
  4. ActiveRecord::Base.establish_connection(
  5. :adapter => "mysql", host => $DB_HOSTNAME,
  6. :database => $DB_NAME,:username => $DB_USERNAME,:password => $DB_PASSWORD)
  7.  
  8. class Sometable < ActiveRecord::Base
  9. end
  10.  
  11. get '/' do
  12. #stuff with Sometable
  13. end
  14.  
  15. # a lot of route handlers..
  16.  
  17. #prevent MySQL server has gone away by verifying connections every 30 minutes.
  18. Thread.new {
  19. loop {
  20. sleep(60*30);
  21. ActiveRecord::Base.verify_active_connections!
  22. }
  23. }.priority = -10
Add Comment
Please, Sign In to add comment