Skip to content

Instantly share code, notes, and snippets.

@tscolari
Last active August 22, 2023 20:54
Show Gist options
  • Save tscolari/3762849 to your computer and use it in GitHub Desktop.
Save tscolari/3762849 to your computer and use it in GitHub Desktop.
Thinking-Sphinx Run in Foreground Task
namespace :ts do
desc "Run Thinking Sphinx in the foreground (for something like foreman)"
task :run_in_foreground => ['ts:stop', 'ts:index'] do
config = ThinkingSphinx::Configuration.instance
controller = config.controller
unless pid = fork
exec "#{controller.bin_path}#{controller.searchd_binary_name} --pidfile --config #{config.configuration_file} --nodetach"
end
Signal.trap('TERM') { Process.kill('TERM', pid) }
Signal.trap('INT') { Process.kill('INT', pid) }
Process.wait(pid)
end
end
Gem::Specification.new do |s|
s.name = 'thinking_sphinx_run_fg_task'
s.version = '1.0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Tiago Scolari'
s.email = 'tscolari@gmail.com'
s.summary = 'Adds a task to run sphinx in foreground'
s.description = 'Runs sphinx in foreground, to be used with foreman.'
s.files = ['thinking_sphinx_run_fg_task.rb', 'thinking_sphinx.rake']
s.require_path = '.'
s.add_development_dependency('thinking-sphinx')
end
module ThinkingSphinxRunFgTask
end
load 'thinking_sphinx.rake' if defined?(Rake)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment