Skip to content

Commit

Permalink
looking good
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermef committed Sep 30, 2012
1 parent 921d298 commit 85cf2ed
Show file tree
Hide file tree
Showing 35 changed files with 9,398 additions and 467 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.sass-cache
.bundle

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "http://rubygems.org"
gem "sinatra"
gem "haml"
gem "compass"

group :test do
gem "rspec"
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ GEM
addressable (2.3.2)
childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
chunky_png (1.2.6)
columnize (0.3.6)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
debugger (1.2.0)
columnize (>= 0.3.1)
debugger-linecache (~> 1.1.1)
Expand All @@ -15,6 +20,7 @@ GEM
diff-lcs (1.1.3)
fakeweb (1.3.0)
ffi (1.1.5)
fssm (0.2.9)
haml (3.1.7)
jasmine (1.2.1)
jasmine-core (>= 1.2.0)
Expand Down Expand Up @@ -43,6 +49,7 @@ GEM
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
rubyzip (0.9.9)
sass (3.2.1)
selenium-webdriver (2.25.0)
childprocess (>= 0.2.5)
libwebsocket (~> 0.1.3)
Expand All @@ -58,6 +65,7 @@ PLATFORMS
ruby

DEPENDENCIES
compass
debugger
fakeweb
haml
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ end
# Jasmine::Headless::Task.new

task :travis do
["rspec spec", "rake jasmine:ci"].each do |cmd|
# ["rspec spec", "rake jasmine:ci"].each do |cmd|
["rspec spec"].each do |cmd|
puts "Starting to run #{cmd}..."
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
raise "#{cmd} failed!" unless $?.exitstatus == 0
Expand Down
3 changes: 3 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require './healthchecker'

Healthchecker.run!
31 changes: 12 additions & 19 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
---
projects:
colaboracoes:
id: colaboracoes
name: Colaborações
url: http://colaboracoes.globo.com/healthcheck

participacoes:
id: participacoes
name: Participações
url: http://participacoes.globo.com/healthcheck

colaboracoes2:
id: colaboracoes2
name: Colaborações2
url: http://colaboracoes.globo.com/healthcheck

participacoes2:
id: participacoes2
name: Participações2
url: http://participacoes.globo.com/healthcheck
globo:
name: Globo
url: http://www.globo.com/
bing:
name: Bing
url: http://br.bing.com/
xang:
name: Xang
url:
- http://xang.com/
- http://xeng.com/
- http://xing.com/
10 changes: 10 additions & 0 deletions config/compass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project_path = Sinatra::Application.root
environment = :development

# This is common configuration
sass_dir = File.join 'views', 'stylesheets'
images_dir = File.join 'static', 'images'
http_path = "/"
http_images_path = "/images"
http_stylesheets_path = "/stylesheets"

60 changes: 36 additions & 24 deletions healthchecker.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
#!/usr/bin/env ruby
require "rubygems"
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
require "bundler/setup"

require 'sinatra'
require 'lib/connection'
require 'yaml'
require 'haml'
require 'json'
require 'compass'

class Healthchecker < Sinatra::Base

before do
@config = YAML::load_file('config.yml')
end
configure do
set :public_folder, File.dirname(__FILE__) + '/static'
set :haml, {:format => :html5, :escape_html => true}
set :sass, {:style => :compact, :debug_info => false}
Compass.add_project_configuration(File.join(Sinatra::Application.root, 'config', 'compass.rb'))
end

get '/' do
haml :index
end
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
sass :"stylesheets/#{params[:name]}", Compass.sass_engine_options
end

get "/config" do
@config.to_json
end
before do
@config = YAML::load_file('config.yml')
end

get '/' do
haml :index
end

get "/project/:project_name" do
project_key = params[:project_name]
project_config = @config['projects'][project_key]
project_links = project_config['url']
project_links = [project_links] unless project_links.is_a? Array
get "/project/:project_name.json" do
content_type :json

errors = project_links.inject([]) do |errors_list, link|
status = Connection.new(link).status_code
errors_list << {server: link, error: status} if status != '200'
errors_list
end
project_key = params[:project_name]
project_config = @config['projects'][project_key]
project_links = project_config['url']
project_links = [project_links] unless project_links.is_a? Array

errors = project_links.inject([]) do |errors_list, link|
status = Connection.new(link).status_code
errors_list << {server: link, error: status} if status != '200'
errors_list
end

result = errors.empty? ? "ok" : "down"
resposta = {project_name: project_key, status: result, errors: errors}
resposta.to_json
end
result = errors.empty? ? "ok" : "down"
resposta = {project_name: project_key, status: result, errors: errors}
resposta.to_json
end
end
Binary file removed public/images/.DS_Store
Binary file not shown.
Binary file removed public/images/art4.jpg
Binary file not shown.
Binary file removed public/images/coracao.png
Binary file not shown.
Binary file removed public/images/headdiv.gif
Binary file not shown.
Binary file removed public/images/logo.jpg
Binary file not shown.
Binary file removed public/images/seperator.png
Binary file not shown.
Binary file removed public/images/sprite_eletro.png
Binary file not shown.
Binary file removed public/images/thumb_bg.png
Binary file not shown.
Loading

0 comments on commit 85cf2ed

Please sign in to comment.