Skip to content

Commit

Permalink
[api] fix start/stop handling of searchd
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Feb 21, 2014
1 parent 37b8fad commit 9f91701
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dist/obsapidelayed
Original file line number Diff line number Diff line change
Expand Up @@ -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 $*"
}
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/api/config/clock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f91701

Please sign in to comment.