Last active
August 22, 2023 20:54
-
-
Save tscolari/3762849 to your computer and use it in GitHub Desktop.
Thinking-Sphinx Run in Foreground Task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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