Reputation: 2783
I tried to work sinatra application, but the error occurs which is very mystery.
#encoding: utf-8
require 'sinatra'
require 'rss'
require 'dalli'
require './url'
require './feed'
set :bind, '0.0.0.0'
configure :production do
require 'newrelic_rpm'
end
...
configure :development do
require 'sinatra/reloader'
end
...
get '/new_movie' do
if params['tag2']
@key = 'tag1=' + params['tag1'] + '&tag2=' + params['tag2']
else
@key = 'tag1=' + params['tag1']
end
configure :production do ####### ERROR OCCURS AT HERE! #######
# if cache exists
if output = settings.cache.get(@key)
@isCacheUsed = true
output
end
end
unless @isCacheUsed
# Thread One
t1 = Thread.new(params['tag1']) do |param_tag1|
@feed_nico = feed_nico(param_tag1)
puts 'nico' if DEBUG_APP
end
# Thread Two
if params['tag2']
t2 = Thread.new(params['tag2']) do |param_tag2|
@feed_vimeo = feed_vimeo(param_tag2)
puts 'vimeo' if DEBUG_APP
end
end
# Main Thread
feed_hatena1 = feed_hatena(params['tag1'])
puts 'hatena1' if DEBUG_APP
t1.join
t2.join if params['tag2']
if params['tag2']
feed = feed_hatena1.append(
@feed_nico, @feed_vimeo).
unique
puts 'append + unique' if DEBUG_APP
else
feed = feed_hatena1.append(@feed_nico).unique
end
content_type = 'text/xml; charset=utf-8'
@output = feed.to_s
end
end
...
Thank you for your help.
Upvotes: 0
Views: 1280
Reputation: 737
You can't call "configure" from within your route. Make sure that all your configuration parameters exist outside of your routes
Upvotes: 1