Skip to content

Instantly share code, notes, and snippets.

@pedro

pedro/gist:16651

Created Oct 14, 2008
Embed
What would you like to do?
diff --git a/app/models/hot_slug.rb b/app/models/hot_slug.rb
index 9798a94..93718c0 100644
--- a/app/models/hot_slug.rb
+++ b/app/models/hot_slug.rb
@@ -8,7 +8,14 @@ class HotSlug < ActiveRecord::Base
end
def railgun_slug
- RestClient::Resource.new("http://#{instance.local_ip}:1000/slugs/#{slug}", 'core', 'ASL938i54lDfU')
+ RestClient::Resource.new("http://#{instance.local_ip}:1000/slugs/#{slug}", :user => 'core', :password => 'ASL938i54lDfU', :headers => environment)
+ end
+
+ def environment
+ app.environment.inject({}) do |header, (key, value)|
+ header["env-#{key}"] = value
+ header
+ end
end
def railgun_server
@@ -28,7 +35,7 @@ class HotSlug < ActiveRecord::Base
def rake(cmd)
Log.debug "rake #{cmd}"
- railgun_slug['rake'].post :cmd => cmd, :env => app.environment
+ railgun_slug['rake'].post :cmd => cmd
end
def log
@@ -44,7 +51,7 @@ class HotSlug < ActiveRecord::Base
end
def server_params
- { :env => app.environment, :faces => face_ips.join(","), :domains => domains.join(",") }
+ { :faces => face_ips.join(","), :domains => domains.join(",") }
end
def start
diff --git a/spec/models/hot_slug_spec.rb b/spec/models/hot_slug_spec.rb
index b40d970..8a3b1c9 100644
--- a/spec/models/hot_slug_spec.rb
+++ b/spec/models/hot_slug_spec.rb
@@ -16,6 +16,11 @@ describe HotSlug do
@hot_slug.load_and_fire
end
+ it "adds a prefix to env keys before adding them to the resource headers" do
+ @app.stub!(:environment).and_return(:database => 'app123')
+ @hot_slug.environment.should == { 'env-database' => 'app123' }
+ end
+
it "starting the server resets crashlog and starts the thin, passing all server params" do
@app.should_receive(:update_attribute).with(:crashlog, nil)
@hot_slug.stub!(:server_params).and_return('VALUE' => 1)
@@ -23,13 +28,6 @@ describe HotSlug do
@hot_slug.start
end
- it "server params includes the app environment (db credentials, etc)" do
- @hot_slug.stub!(:domains).and_return([])
- @hot_slug.stub!(:face_ips).and_return([])
- @app.stub!(:environment).and_return(:the_env)
- @hot_slug.server_params[:env].should == :the_env
- end
-
it "server params includes the list of face ips which railgun will use to contact each hermes process" do
@app.stub!(:environment)
@hot_slug.stub!(:domains).and_return([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment