Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

stauts: check solr server utf-8 encoding, close #280.

  • Loading branch information...
commit 0985281ebef87387a11099fe4327a2f744d3753e 1 parent 38a2dca
Saber Ma authored
26 app/admin/shops.rb
View
@@ -49,5 +49,31 @@
@shop_shop_js = "#{ActionController::Base.asset_host}#{theme.asset_url('fancybox.js')}"
@shop_product_photo = @shop.products.first.index_photo
end
+ begin 'server' # 服务器
+ begin
+ @server_redis = Resque.redis.ping
+ rescue => e
+ puts "Redis Server Error:#{e}"
+ end
+ begin
+ id = @shop.id
+ @server_sunspot = Sunspot.search(Page) do
+ keywords '关于'
+ with :shop_id, id
+ end.results
+ rescue => e
+ puts "Sunspot Server Error:#{e}"
+ end
+ begin
+ keywords = 'héllo'
+ url = "#{Sunspot.config.solr.url}/select?q=#{URI.escape(keywords)}&params=explicit&wt=json"
+ response_keywords = JSON(HTTParty.get(url).body)['responseHeader']['params']['q']
+ @server_solr_get = (keywords == response_keywords)
+ response_keywords = JSON(HTTParty.post(url).body)['responseHeader']['params']['q']
+ @server_solr_post = (keywords == response_keywords)
+ rescue => e
+ puts "Solr Server UTF-8 Error:#{e}"
+ end
+ end
end
end
43 app/views/active_admin/shops/state.html.haml
View
@@ -3,10 +3,10 @@
clear: both
}
table {
- width: 750px;
+ width: 800px;
}
td.title {
- width: 200px;
+ width: 250px;
}
td.state {
width: 100px;
@@ -40,6 +40,45 @@
%td.desc 出错时的相应描述
%td.view 操作
+%h2 服务器
+%table
+ %tr
+ %td.title 是否能连接到Redis服务器
+ %td#server_redis.state
+ -if @server_redis
+ %span.status.ok 正常
+ -else
+ %span.status.error 出错
+ %td.desc Redis可能未启动
+ %td.view
+ %tr
+ %td.title 是否能连接到Sunspot服务器
+ %td#server_sunspot.state
+ -if @server_sunspot
+ %span.status.ok 正常
+ -else
+ %span.status.error 出错
+ %td.desc Sunspot可能未启动
+ %td.view=link_to '查看', "#{Sunspot.config.solr.url}/admin", target: :_blank
+ %tr
+ %td.title Solr服务器是否支持utf-8编码(Get)
+ %td#server_solr.state
+ -if @server_solr_get
+ %span.status.ok 正常
+ -else
+ %span.status.error 出错
+ %td.desc Solr容器不支持utf-8编码会导致无法查询中文关键字;下载solr压缩包,使用example/exampledocs/test_utf8.sh测试;推荐使用jetty7作为solr服务器,tomcat5,6,7都存在编码问题
+ %td.view=link_to '下载', "http://www.apache.org/dyn/closer.cgi/lucene/solr/", target: :_blank
+ %tr
+ %td.title Solr服务器是否支持utf-8编码(Post)
+ %td#server_solr.state
+ -if @server_solr_post
+ %span.status.ok 正常
+ -else
+ %span.status.error 出错
+ %td.desc 同上(Get方式)
+ %td.view
+
%h2 Libxml2
%table
%tr
7 config/deploy.rb
View
@@ -1,4 +1,5 @@
-#export CAP_RVM_RUBY=ruby-1.9.2
+#变量定义到~/.zshrc
+#export CAP_RVM_RUBY=ruby-1.9.3-p0
#export CAP_PORT=10000
#export CAP_WEB_HOST=188.188.188.188
#export CAP_APP_HOST=$CAP_WEB_HOST
@@ -43,12 +44,12 @@
run "kill -s USR2 `cat /tmp/unicorn.#{application}.pid`"
end
- # scp -P $CAP_PORT config/{database,sms,alipay,admin_users}.yml $CAP_USER@$CAP_APP_HOST:/u/apps/shopqi/shared/config/
+ # scp -P $CAP_PORT config/{database,sms,alipay,admin_users,sunspot}.yml $CAP_USER@$CAP_APP_HOST:/u/apps/shopqi/shared/config/
# scp -P $CAP_PORT config/unicorn.conf.rb $CAP_USER@$CAP_APP_HOST:/u/apps/shopqi/shared/config/
# scp -P $CAP_PORT config/initializers/secret_token.rb $CAP_USER@$CAP_APP_HOST:/u/apps/shopqi/shared/config/initializers/
desc "Symlink shared resources on each release" # 配置文件
task :symlink_shared, roles: :app do
- %w(database.yml sms.yml alipay.yml admin_users.yml unicorn.conf.rb).each do |secure_file|
+ %w(database.yml sms.yml alipay.yml admin_users.yml sunspot.yml unicorn.conf.rb).each do |secure_file|
run "ln -nfs #{shared_path}/config/#{secure_file} #{release_path}/config/#{secure_file}"
end
run "ln -nfs #{shared_path}/config/initializers/secret_token.rb #{release_path}/config/initializers/secret_token.rb"
31 solr/jetty_solr.xml
View
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
+<!-- do not use http://wiki.apache.org/solr/SolrJetty, just copy this to contexts directory -->
+<Configure class="org.eclipse.jetty.webapp.WebAppContext">
+
+ <Array id="plusConfig" type="java.lang.String">
+ <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
+ <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> <!-- add for JNDI -->
+ <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> <!-- add for JNDI -->
+ <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.TagLibConfiguration</Item>
+ </Array>
+
+ <Set name="ConfigurationClasses"><Ref id="plusConfig"/></Set>
+
+ <Set name="contextPath">/solr</Set>
+ <Set name="war">/var/lib/solr/solr.war</Set>
+
+ <New class="org.eclipse.jetty.plus.jndi.EnvEntry"> <!-- (http://wiki.eclipse.org/Jetty/Feature/JNDI) modify start.ini, add 'plus' to OPTIONS -->
+ <Arg>/solr/home</Arg>
+ <Arg type="java.lang.String">/var/lib/solr</Arg>
+ </New>
+
+ <Set name="extractWAR">true</Set>
+ <Set name="copyWebDir">false</Set>
+ <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
+
+</Configure>
Please sign in to comment.
Something went wrong with that request. Please try again.