Permalink
Browse files

Added the basic http app

Fixed up the clone ferrets
Started work on http_warmup currently it is not working becuase of some issues with ruby gems and crashs oddly when ran with foreman
  • Loading branch information...
1 parent 6e40968 commit 78d3d4429d6e3baa7925c568aa10317bc9aa4317 Eric Fode committed Dec 17, 2012
View
No changes.
View
@@ -0,0 +1,3 @@
+source :rubygems
+gem 'sinatra'
+gem 'thin'
@@ -0,0 +1,24 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ daemons (1.1.9)
+ eventmachine (1.0.0)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ sinatra (1.3.3)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ thin (1.5.0)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ sinatra
+ thin
View
@@ -0,0 +1 @@
+web: bundle exec ruby web.rb -p $PORT
View
@@ -0,0 +1,5 @@
+require 'sinatra'
+
+get '/' do
+ "hello world"
+end
View
@@ -2,15 +2,22 @@
require_relative "../lib/ferret"
-bash(retry: 2, name: :heroku_info_create, stdin: <<'EOF')
- heroku info --app $TARGET_APP || {
- heroku create $TARGET_APP \
- && heroku plugins:install https://github.com/heroku/manager-cli.git \
- && heroku manager:transfer --app $TARGET_APP --to $ORG
- }
+bash(retry: 1, name: :setup, stdin: <<'EOF')
+ cd $FERRET_DIR/app/basic_http
+ rm /.git
+ heroku create $SERVICE_APP_NAME
+ git init
+ git add *
+ git commit -m "initial"
+ git push heroku master
+ cd $FERRET_DIR
EOF
+run_every_time do
bash(name: :clone, pattern: /cloned an empty repository/, stdin: <<'EOF')
rm -rf ./app
- git clone git@heroku.com:$TARGET_APP.git ./app
+ git clone git@heroku.com:$SERVICE_APP_NAME.git ./app
EOF
+end
+
+run forever: true
View
@@ -2,15 +2,22 @@
require_relative "../lib/ferret"
-bash(retry: 2, name: :heroku_info_create, stdin: <<'EOF')
- heroku info --app $TARGET_APP || {
- heroku create $TARGET_APP -s bamboo \
- && heroku plugins:install https://github.com/heroku/manager-cli.git \
- && heroku manager:transfer --app $TARGET_APP --to $ORG
- }
+bash(retry: 1, name: :setup, stdin: <<'EOF')
+ cd $FERRET_DIR/app/basic_http
+ rm /.git
+ heroku create $SERVICE_APP_NAME -s bamboo
+ git init
+ git add *
+ git commit -m "initial"
+ git push heroku master
+ cd $FERRET_DIR
EOF
+run_every_time do
bash(name: :clone, pattern: /cloned an empty repository/, stdin: <<'EOF')
rm -rf ./app
- git clone git@heroku.com:$TARGET_APP.git ./app
+ git clone git@heroku.com:$SERVICE_APP_NAME.git ./app
EOF
+end
+
+run forever: true
View
@@ -2,15 +2,23 @@
require_relative "../lib/ferret"
-bash(retry: 2, name: :heroku_info_create, stdin: <<'EOF')
- heroku info --app $TARGET_APP || {
- heroku create $TARGET_APP \
- && heroku plugins:install https://github.com/heroku/manager-cli.git \
- && heroku manager:transfer --app $TARGET_APP --to $ORG
- }
+bash(retry: 1, name: :setup, stdin: <<'EOF')
+ cd $FERRET_DIR/app/basic_http
+ rm /.git
+ heroku create $SERVICE_APP_NAME
+ git init
+ git add *
+ git commit -m "initial"
+ git push heroku master
+ cd $FERRET_DIR
EOF
-bash(name: :clone, pattern: /cloned an empty repository/, stdin: <<'EOF')
+
+
+run_every_time do
+ bash(name: :clone, pattern: /cloned an empty repository/, stdin: <<'EOF')
rm -rf ./app
- git clone ssh://git@gitproxy-default.herokussl.com:2222/$TARGET_APP.git
+ git clone ssh://git@gitproxy-default.herokussl.com:2222/$SERVICE_APP_NAME.git
EOF
+end
+run forever: true
View
@@ -0,0 +1,58 @@
+#!/usr/bin/env ruby
+require_relative "../lib/ferret"
+require 'sequel'
+require 'resolv'
+
+
+run_every_time do
+ bash(name: :clean, timeout:50,stdin: <<-'EESTD')
+ heroku apps:delete --app $SERVICE_APP_NAME --confirm $SERVICE_APP_NAME
+ heroku create $SERVICE_APP_NAME
+ heroku addons:add heroku-postgresql --app $SERVICE_APP_NAME
+EESTD
+
+ test name: :tryresolve, timeout:200 do
+ ENV['DATABASE_URL'] =`heroku config --app $SERVICE_APP_NAME | awk '/HEROKU_POSTGRESQL/ {print $2;}'`
+ uri = URI.parse(ENV['DATABASE_URL'])
+ host = uri.host
+ puts "DB Hostname: #{host}"
+ begin
+ private_ip = Resolv.getaddress(host)
+ rescue => e
+ puts "Error resolving #{host}"
+ puts e.message
+ puts e.backtrace.join("\n")
+ end
+ puts "DB Private IP: #{private_ip}"
+ puts "dyno hostname: #{`hostname`}"
+ puts "dyno private inet: #{`/sbin/ifconfig | grep "inet addr:" | grep -v 127.0.0.1`}"
+ t1 = Thread.new do
+ begin
+ db1 = Sequel.connect(ENV['DATABASE_URL'])
+ puts "With host: Database?: #{db1.test_connection}"
+ rescue => e
+ puts "Error connecting with hostname"
+ puts e.message
+ puts e.backtrace.join("\n")
+ return 1
+ end
+ end
+
+ uri.host = private_ip
+ t2 = Thread.new do
+ begin
+ db2 = Sequel.connect(uri.to_s)
+ puts "With private ip: Database?: #{db2.test_connection}"
+ rescue => e
+ puts "Error connecting with private IP"
+ puts e.message
+ puts e.backtrace.join("\n")
+ return 1
+ end
+ end
+ [t1, t2].each(&:join)
+ puts "-"*80
+ end
+end
+
+run forever: true

0 comments on commit 78d3d44

Please sign in to comment.