Quietus

Simple status check web server.

Build Status Gem Version

Why

You might want to use this to provide a status check to an AWS ELB where you don't have a web server in your app. Having a status check lets you quietly kill unhealthy instances and replace them.

See these AWS Docs

Usage

Passive (TCP Server only)

This setup requires you to have an ELB setup monitoring the specified port for a TCP response.

require 'quietus'

hostname = 'localhost'
port     = '2347'

# quietus runs your check in a loop, so you might want to sleep
def your_status_check
  sleep 1
  is_my_app_healthy?
end

# quietus is blocking so you might want to run it in a thread or fork depending on your Ruby version
t = Thread.new do
  Quietus::PassiveServer.new(optional_hostname, optional_port) { your_status_check }
end

The Passive Quietus server will accept a TCP connection if your_status_check is truthy, otherwise it will refuse

By default quietus runs on port 2347.

Active (uses AWS SDK to contact Health Check API)

This setup will actively contact AWS to update instance health. Use this if you don't want an ELB.

require 'quietus'
require 'aws-sdk'

# The server will not contact AWS unless the following is set:
ENV['APP_ENV'] == 'production'

# You'll need to get an auto_scaling_instance from the API
auto_scaling = AWS::AutoScaling.new
auto_scaling_instance = auto_scaling.instances['i-12345678']

# quietus runs your check in a loop, so you might want to sleep
def your_status_check
  sleep 1
  is_my_app_healthy?
end

# quietus is blocking so you might want to run it in a thread or fork depending on your Ruby version
t = Thread.new do
  Quietus::ActiveServer.new(auto_scaling_instance) { your_status_check }
end

It's important to remember if your app simply crashes, using the active setup the health check API won't get updated.