Skip to content

Commit

Permalink
renamed project
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeiters committed Mar 9, 2011
1 parent 852f0b0 commit 76cb819
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 49 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
@@ -1,4 +1,4 @@
Copyright (c) 2011 mdeiters
Copyright (c) 2011 Matthew Deiters

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
6 changes: 3 additions & 3 deletions README.rdoc
@@ -1,8 +1,8 @@
= health-status
= healthy

Description goes here.

== Contributing to health-status
== Contributing to healthy

* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
Expand All @@ -14,6 +14,6 @@ Description goes here.

== Copyright

Copyright (c) 2011 mdeiters. See LICENSE.txt for
Copyright (c) 2011 Matthew Deiters. See LICENSE.txt for
further details.

6 changes: 3 additions & 3 deletions Rakefile
Expand Up @@ -12,8 +12,8 @@ require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "health-status"
gem.homepage = "http://github.com/mdeiters/health-status"
gem.name = "healthy"
gem.homepage = "http://github.com/mdeiters/healthy"
gem.license = "MIT"
gem.summary = %Q{Enables apps to have a status or diagnostics page}
gem.description = %Q{Enables apps to have a status or diagnostics page}
Expand Down Expand Up @@ -42,7 +42,7 @@ Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "health-status #{version}"
rdoc.title = "healthy #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
4 changes: 2 additions & 2 deletions bin/status-web → bin/healthy-web
Expand Up @@ -8,8 +8,8 @@ rescue LoadError
require 'vegas'
end
require 'activesupport'
require 'health-status'
require 'healthy'

Vegas::Runner.new(HealthStatus::Server, 'status-web', {}) do |runner, opts, app|
Vegas::Runner.new(Healthy::Server, 'healthy-web', {}) do |runner, opts, app|

end
10 changes: 5 additions & 5 deletions health-status.gemspec → healthy.gemspec
Expand Up @@ -4,7 +4,7 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{health-status}
s.name = %q{healthy}
s.version = "0.1.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
Expand All @@ -24,17 +24,17 @@ Gem::Specification.new do |s|
"README.rdoc",
"Rakefile",
"VERSION",
"lib/health-status.rb",
"spec/health-status_spec.rb",
"lib/healthy.rb",
"spec/healthy_spec.rb",
"spec/spec_helper.rb"
]
s.homepage = %q{http://github.com/mdeiters/health-status}
s.homepage = %q{http://github.com/mdeiters/healthy}
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.6}
s.summary = %q{Enables apps to have a status or diagnostics page}
s.test_files = [
"spec/health-status_spec.rb",
"spec/healthy_spec.rb",
"spec/spec_helper.rb"
]

Expand Down
2 changes: 1 addition & 1 deletion lib/base.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class Diagnostic
# all checks are expected to implement methods passed?, warning?, info
# all tools are expected to implement methods info
Expand Down
7 changes: 5 additions & 2 deletions lib/diagnostic.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class Diagnostic
class << self
def normalize_name(name)
Expand Down Expand Up @@ -49,7 +49,10 @@ def current_server
end

def monitor(diagnostic)
(@diagnostics ||= []) << diagnostic
@diagnostics ||= []
exsisting = @diagnostics.detect{|exsisting| exsisting.name == diagnostic.name }
@diagnostics.delete(exsisting) if exsisting
@diagnostics << diagnostic
end

def diagnostics
Expand Down
2 changes: 1 addition & 1 deletion lib/disk_space.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class DiskSpace < Diagnostic::DistributedBase
def name
'Disk Space'
Expand Down
12 changes: 6 additions & 6 deletions lib/distributed_base.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class Diagnostic
class DistributedBase < Base
attr_reader :originator_of_request
Expand All @@ -13,10 +13,14 @@ def self.run_on=(value)

def handles?(name)
name_match = Diagnostic.normalize_name(name).include?(normalized_name)
@originator_of_request = true if name_match && !name.include?('+standalone')
@originator_of_request = true if name_match && !name.include?('+remote')
return name_match
end

def remote_server_info(server)
`curl -H 'Host: #{Diagnostic.site_host}' http://#{server}/status?info=#{normalized_name}+remote`
end

def ask_other_servers?
originator_of_request == true
end
Expand Down Expand Up @@ -44,10 +48,6 @@ def info
response
end

def remote_server_info(server)
`curl -H 'Host: #{Diagnostic.site_host}' http://#{server}/status?info=#{normalized_name}+standalone`
end

def server_info
status
end
Expand Down
2 changes: 1 addition & 1 deletion lib/env_check.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class EnvCheck < Diagnostic::DistributedBase
def name
'Environment'
Expand Down
2 changes: 1 addition & 1 deletion lib/gem_list.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class GemList < Diagnostic::DistributedBase
def name
'Installed Ruby And Gems'
Expand Down
11 changes: 0 additions & 11 deletions lib/health-status.rb

This file was deleted.

11 changes: 11 additions & 0 deletions lib/healthy.rb
@@ -0,0 +1,11 @@
DIAGNOSTIC_LOGGER = defined?(Rails) ? Rails.logger : require('logger') && Logger.new($stdout)

require 'diagnostic'
require 'sinatra'
require 'server'
require 'base'
require 'distributed_base'
require('gem_list') && Healthy::Diagnostic.monitor(Healthy::GemList)
require('env_check') && Healthy::Diagnostic.monitor(Healthy::EnvCheck)
require('disk_space') && Healthy::Diagnostic.monitor(Healthy::DiskSpace)
require('revision_deployed') && Healthy::Diagnostic.monitor(Healthy::RevisionDeployed)
2 changes: 1 addition & 1 deletion lib/revision_deployed.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class RevisionDeployed < Diagnostic::DistributedBase
def name
'Subversion Revision'
Expand Down
2 changes: 1 addition & 1 deletion lib/server.rb
@@ -1,4 +1,4 @@
module HealthStatus
module Healthy
class Server < Sinatra::Base
dir = File.dirname(File.expand_path(__FILE__))

Expand Down
8 changes: 4 additions & 4 deletions lib/views/show.erb
Expand Up @@ -3,10 +3,10 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel='stylesheet' href='<%= url_for("screen.css") %>' type='text/css' media='screen' />
<title>Status : <%= HealthStatus::Diagnostic.status.to_s.upcase %></title>
<title>Status : <%= Healthy::Diagnostic.status.to_s.upcase %></title>
</head>
<body class="<%= HealthStatus::Diagnostic.status %>">
<h1><%= HealthStatus::Diagnostic.status.to_s.upcase %></h1>
<body class="<%= Healthy::Diagnostic.status %>">
<h1><%= Healthy::Diagnostic.status.to_s.upcase %></h1>
<div id="main">
<ul>
<% @checks.each do |check| %>
Expand Down Expand Up @@ -39,7 +39,7 @@

<h4 id="refresh-msg" class='left'></h4>
<h4 class='right'>
<%= HealthStatus::Diagnostic.current_server %>
<%= Healthy::Diagnostic.current_server %>
<a href='#headers' onclick="$('#headers').toggle(); return false;">(show headers)</a>
</h4>
<div id='headers'><h6><%= request.env.keys.sort.collect{|n| "#{n} = #{request.env[n]}" }.join('<br>') %></h6></div>
Expand Down
2 changes: 1 addition & 1 deletion spec/base_spec.rb
@@ -1,6 +1,6 @@
require 'spec/spec_helper'

module HealthStatus
module Healthy

describe Diagnostic::Base do
it 'returns a status of :pass if a diagnostic indicates passed? and there are no warnings' do
Expand Down
11 changes: 9 additions & 2 deletions spec/diagnostic_spec.rb
@@ -1,6 +1,6 @@
require 'spec/spec_helper'

module HealthStatus
module Healthy
describe Diagnostic do
before :each do
Diagnostic.flush_diagnostics!
Expand Down Expand Up @@ -39,6 +39,13 @@ def name; 'test123'; end
Diagnostic.monitor(test_check_class)
Diagnostic.find('test123').should be_instance_of(test_check_class)
end


it 'should only have one instance of diagnostic even if multiple exsist so development autoreloading works' do
test_check_class = Class.new(Diagnostic::Base)
Diagnostic.monitor(test_check_class)
Diagnostic.monitor(test_check_class)
loaded_diagnostics = Diagnostic.instance_variable_get("@diagnostics")
loaded_diagnostics.uniq.should == loaded_diagnostics
end
end
end
4 changes: 2 additions & 2 deletions spec/distributed_base_spec.rb
@@ -1,6 +1,6 @@
require 'spec/spec_helper'

module HealthStatus
module Healthy

describe Diagnostic::DistributedBase do

Expand All @@ -26,7 +26,7 @@ def server_info
response.should include("amdc-lamp-lx12.amdc.mckinsey.com\nother server test")
end

it "should perform server_info only on the current server if name contains 'standalone' because another check originated the request" do
it "should perform server_info only on the current server if name contains 'remote' because another check originated the request" do
test_instance = Class.new(Diagnostic::DistributedBase) do
def name
'Test Farm Diagnostic'
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
@@ -1,7 +1,7 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'health-status'
require 'healthy'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Expand Down

0 comments on commit 76cb819

Please sign in to comment.