phoet / asin

:books: :package: Amazon Simple INterface - Support for ItemLookup, SimilarityLookup, Search, BrowseNode and Cart Operations
http://asin.herokuapp.com/
167 stars 59 forks source link

ASIN + Unicorn? #18

Closed netwire88 closed 12 years ago

netwire88 commented 12 years ago

I just migrated from Thin to Unicorn, everything's working except ASIN. I'm getting the following error, do I need to configure an "after_fork" method or something in order for ASIN to work with Unicorn?

Here's a portion of the error message:

<div id="Framework-Trace" style="display: none;">
      <pre><code>confiture (0.1.2) lib/confiture/configuration.rb:152:in `method_missing'
confiture (0.1.2) lib/confiture/configuration.rb:123:in `blank?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `block in valid?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `each'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `none?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `valid?'
confiture (0.1.2) lib/confiture/configuration.rb:95:in `validate!'
asin (1.1.0) lib/asin/client.rb:360:in `call'
asin (1.1.0) lib/asin/client.rb:196:in `search'
actionpack (3.2.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.6) lib/abstract_controller/base.rb:167:in `process_action'
phoet commented 12 years ago

do you have the asin configuration in lib? or did you clone the repos in there?

did you use an initializer to configure the repo?

did you put lib into the autoloadpath?

i dont think that this error is asin specific. it looks like an error in your load path setup.

netwire88 commented 12 years ago

I agree it might be a configuration issue. My ASIN is configured by adding asin.rb to the /config/initializers directory. Here's the content of it:

ASIN::Configuration.configure do |config|
  config.secret        = ENV['AMAZON_SECRET']
  config.key           = ENV['AMAZON_KEY']
  config.associate_tag = ENV['AMAZON_TAG']
  config.version       = ENV['AMAZON_VERSION']
end

How do I configure it with unicorn.rb?

To be specific, it fails in Configuration module, line 123:

      def blank?(key)
        val = self.send key   <---- throws Exception, key input = secret
        val.nil? || val.empty?
      end
phoet commented 12 years ago

try putting require "asin" in the initializer.

no idea what could cause this, did not use unicorn upto now