我在轮胎上使用ElasticSearch并在Heroku上托管我的应用程序。盆景服务器停机时该怎么办?
昨天晚上,当盆景服务器关闭时,我的整个应用程序崩溃。 当我试图部署应用的Heroku,轮胎试图连接和创建索引,并投掷了错误,所以我不得不从全系车型将我Tire
代码到unless
声明:
unless ENV['ES_DISABLED']
# Elastic Search
#
include Tire::Model::Search
include Tire::Model::Callbacks
index_name INDEX_NAME
tire.mapping do
indexes :id, :type => 'string', :index => :not_analyzed
indexes :content, analyzer: 'snowball', boost: 100
end
end
当然,我中在Heroku上设置ES_DISABLED
常数为true
。
我想为将来的类似错误做好准备。有没有更好的方法来避免它们?
我不认为在部署代码或引导应用程序时创建索引是轮胎默认设置。你确定这不是你实施的吗? – phoet 2013-03-05 18:41:31
它在部署到heroku时发生。所以也许heroku触发重新生成索引。 – tomekfranek 2013-03-05 18:48:16
@phoet轮胎确实这样做,但它试图处理连接问题 – karmi 2013-03-06 18:46:54