From 9f917018c2e6f5b44d5d059ab15059dc60cfca29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 21 Feb 2014 11:47:27 +0100 Subject: [PATCH] [api] fix start/stop handling of searchd --- dist/obsapidelayed | 10 +++++++++- src/api/config/clock.rb | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dist/obsapidelayed b/dist/obsapidelayed index a77f4ff52ad..744434d3c5c 100755 --- a/dist/obsapidelayed +++ b/dist/obsapidelayed @@ -39,10 +39,10 @@ API_ROOT=/srv/www/obs/api CLOCKWORKD=/usr/bin/clockworkd +export RAILS_ENV="production" function run_in_api { - export RAILS_ENV="production" # startproc only works for classical daemons chroot --userspec=wwwrun:www / /bin/bash -c "cd $API_ROOT && /usr/bin/bundle exec $*" } @@ -57,14 +57,22 @@ case "$1" in start) echo -n "Starting OBS api delayed job handler " run_in_api script/delayed_job.api.rb start -n $NUM + rc_status -v + echo -n "Starting OBS api clock daemon " run_in_api $CLOCKWORKD -l -c config/clock.rb start rc_status -v + # searchd got started by clockd ;; stop) echo -n "Shutting down OBS api delayed job handler " run_in_api script/delayed_job.api.rb stop + rc_status -v + echo -n "Shutting down OBS api clock daemon " run_in_api $CLOCKWORKD -l -c config/clock.rb stop rc_status -v + echo -n "Shutting down OBS searchd daemon " + chroot --userspec=wwwrun:www / /bin/bash -c "cd $API_ROOT && /usr/bin/bundle exec rake ts:stop" + rc_status -v ;; try-restart|condrestart) if test "$1" = "condrestart"; then diff --git a/src/api/config/clock.rb b/src/api/config/clock.rb index 441e9d1d1e2..c74988e04b0 100644 --- a/src/api/config/clock.rb +++ b/src/api/config/clock.rb @@ -49,12 +49,16 @@ module Clockwork ActiveRecord::Base.connection_pool.with_connection do |sql| interface = ThinkingSphinx::RakeInterface.new interface.stop + interface.index interface.start + @avoid_phinx_index_on_first_run = true end end every(1.hour, 'reindex sphinx', thread: true) do - ThinkingSphinx::RakeInterface.new.index + if @avoid_phinx_index_on_first_run + ThinkingSphinx::RakeInterface.new.index + end end every(1.day, 'refresh dirties') do