Project

stay_awake

0.0
No commit activity in last 3 years
No release in over 3 years
Requests websites so they won't fall asleep. Like on Heroku.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

 Project Readme

stay_awake Gem Version Dependency Status

About

stay_awake requests websites periodically. It's written especially for Heroku, that puts applications to sleep when there are no requests coming in.

Installation

Gem

$ gem install stay_awake

Bundler

gem 'stay_awake'

Bundler (head)

gem 'stay_awake', :github => 'tbuehlmann/stay_awake'

Usage

buzzer = StayAwake.configure do |c|
  c.app_name = 'app_name'
end

buzzer.buzz

Sinatra

Put the StayAwake.configure block inside Sinatra's configure block, run buzz and you're done:

# app.rb

class App < Sinatra::Base
  configure :production do
    StayAwake.configure do |c|
      c.app_name = 'app_name'
    end.buzz
  end

  # …
end

Rails

Put the StayAwake.configure block inside an initializer, run buzz and you're done:

# config/initializers/stay_awake.rb

if Rails.env.production?
  StayAwake.configure do |c|
    c.app_name = 'app_name'
  end.buzz
end

Configuration Defaults

Configuration Type Default
app_name String nil
url string nil
request_method Symbol :head
interval Integer 300
logger Logger Logger.new(STDOUT)
strategy Class StayAwake.strategies

You can either use app_name or url, but url has precedence over app_name. If just app_name is given, it will be translated to http://app_name.herokuapp.com/.

strategy takes a single Class or Array of Classes that mixed in the Strategy Module. If an Array is given, each Strategy is tested for availability. The first available Strategy will be used for buzzing.

When using EM-HTTP-Request, the buzzing will begin on the next_tick. When using httparty or Net::HTTP, buzzing will begin immediately (using a Thread).

Supported HTTP Libraries