自动调动在/etc/init.d 里加 欄位是啥么意思,字段?可以加很多欄位还可以加权重。
searchable(:ignore_attribute_changes_of=>ignored_index_attributes,
:if => proc { |model| !model.deleted_at }) do
text :name, :stored => true,:more_like_this=>true
text :token_name do
Topic.tokens(name)
end
#text :content
string :user_id
time :created_at
end
hits= Sunspot.search([Question,Topic,User]) do
keywords params[:query] do
# fields(:conent, :name => 2.0)
boost_fields :name => 2.0
query_phrase_slop 1
end
adjust_solr_params do |sunspot_params|
sunspot_params[:start] = 0
sunspot_params[:rows] = 9
end
end.hits
建议先做数据库优化,索引很重要,可以考虑分表,读写分离。实时性不是很高的需求不建议用队列,这种一个操作就要更改上 1000 万条数据的需求真的并不多,客户又不要求你一下把这上 1000 万的数据给列出来。
报名,求,各种求,跪求
刚去转了圈,有很不错的沙发。
恩,菜式有限制,配送范围也有限制。这是要做成全国范围的还是同城的?
这个 idea 不错,看来以后厨师得一边做菜一边看着网站有没有人下订单了,特别中国,独门秘方,传男不传女的菜式,肯定有人订
#1 楼 @minix 感谢 error_page 不起作用,http://leweiup.com/questions/836
喜欢写文档 这种人才很少哦
#1 楼 @quakewang 谢谢,原来可以这样解决
求解~
么有人遇到相似的问题么?
to_a 和 all ,first,last 都可以立即执行,问题是 view 里的 = paginate @targets 用不了了
大家有这种问题么?还是我环境出问题了?
Question.singleton_class.superclass == Question.superclass.singleton_class => true
看到满屏招 ruby 程序员的,我感到很 happy
#9 楼 @calebx 感谢纠正 想起 unicorn 的重启好像用的 run "kill -USR2 `cat #{deploy_to}/current/tmp/pids/unicorn.pid`" 看了下 unicorn 源码:
#lib/unicorn/http_server.rb
case SIG_QUEUE.shift
when :QUIT # graceful shutdown
break
when :TERM, :INT # immediate shutdown
stop(false)
break
when :USR1 # rotate logs
logger.info "master reopening logs..."
Unicorn::Util.reopen_logs
logger.info "master done reopening logs"
kill_each_worker(:USR1)
when :USR2 # exec binary, stay alive in case something went wrong
reexec
#.....
end
def reexec
#....
self.reexec_pid = fork do
listener_fds = Hash[LISTENERS.map do |sock|
# IO#close_on_exec= will be available on any future version of
# Ruby that sets FD_CLOEXEC by default on new file descriptors
# ref: http://redmine.ruby-lang.org/issues/5041
sock.close_on_exec = false if sock.respond_to?(:close_on_exec=)
[ sock.fileno, sock ]
end]
ENV['UNICORN_FD'] = listener_fds.keys.join(',')
Dir.chdir(START_CTX[:cwd])
cmd = [ START_CTX[0] ].concat(START_CTX[:argv])
# avoid leaking FDs we don't know about, but let before_exec
# unset FD_CLOEXEC, if anything else in the app eventually
# relies on FD inheritence.
(3..1024).each do |io|
next if listener_fds.include?(io)
io = IO.for_fd(io) rescue next
IO_PURGATORY << io
io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
end
# exec(command, hash) works in at least 1.9.1+, but will only be
# required in 1.9.4/2.0.0 at earliest.
cmd << listener_fds if RUBY_VERSION >= "1.9.1"
logger.info "executing #{cmd.inspect} (in #{Dir.pwd})"
before_exec.call(self)
exec(*cmd)
end
proc_name 'master (old)'
#...
end
before_fork do |server, worker|
old_pid = "#{Rails.root}/tmp/pids/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
puts "Send 'QUIT' signal to unicorn error!"
end
end
end
#6 楼 @clc3123 这个是 VMware's Cloud Application Platform 的源代码,我是拉下来学习学习的 https://github.com/derekcollison/vcap
very good!