简体   繁体   中英

rails3 thinking-sphinx and cron job

have a cron job that calls

cd /Users/me/rails/current && bundle exec rake ts:rebuild >> /Users/me/log/sphinx_index.log

the task calls up the proper release. Runs through all the indices, runs through all the scores, the declares 'Started successfully (pid 53801).'

Run a search and instead get the unfortunate message:

undefined method `constantize' for 0:Fixnum

manually entering into the app's directory and launching rake ts:rebuild (both with and without bundle exec), returns the app to its happy state.

The only difference I see is that the manual task returns:

WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /Users/me/rails/shared/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
DEPRECATION WARNING: Rake tasks in vendor/plugins/criteriaquery/tasks are deprecated. Use lib/tasks instead. (called from /Users/me/rails/shared/bundle/ruby/1.8/gems/rails-2.3.10/lib/tasks/rails.rb:10)

whereas the log file makes no mention of this.

Attempts at setting cron jobs for other apps, under rails3 have also failed but not investigated seriously, given the unresolved issue at hand.

Full stack trace follows:

/Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:982:in class_from_crc' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:961:in instances_from_matches' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/ordered_hash.rb:115:in each' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/ordered_hash.rb:115:in each' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:959:in instances_from_matches' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:465:in compose_results' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:442:in populate' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:603:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinki ng-sphinx-1.5.0/lib/thinking_sphinx/search.rb:603:in retry_on_stale_index' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:419:in populate' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:286:in total_entries' /Users/its/rails/releases/20130829144322/app/views/ricerca/risultati.html.erb:1:in _run_erb_app47views47ricerca47risultati46html46erb' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/renderable.rb:34:in send' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/renderable.rb:34:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:306:in with_template' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/renderable.rb:30:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/template.rb:205:in render_template' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:265:in render_template' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:265:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:348:in _render_with_layout' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:262:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:1252:in render_for_file' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:936:in render_without_benchmark' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:51:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:in ms' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in realtime' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:in ms' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:51:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:1328:in default_render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:1334:in perform_action_without_filters' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/filters.rb:617:in call_filters' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/filters.rb:610:in perform_action_without_benchmark' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:in ms' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in realtime' /Users/its/rails/shared/ bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:in ms' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/rescue.rb:160:in perform_action_without_flash' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/flash.rb:151:in perform_action' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:532:in send' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:532:in process_without_filters' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/filters.rb:606:in process' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:391:in process' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/a ction_controller/base.rb:386:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/routing/route_set.rb:438:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:87:in dispatch' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:121:in _call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:130:in build_middleware_stack' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:29:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:29:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in cache' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:9:in cache' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:28:in cache' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:28:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/warden-0.10.7/lib/warden/manager.rb:35:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/warden-0.10.7/lib/warden/manager.rb:34:in catch' /Users/its/rails/shared/bundle/ruby/1.8/gems/warden-0.10.7/lib/warden/manager.rb:34:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/string_coercion.rb:25:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/head.rb:9:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/methodoverride.rb:24:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/params_parser.rb:15:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/actio n_controller/session/cookie_store.rb:100:in call' /Users/its/rails/shared/bundle/ruby/1.8/bundler/gems/devise-efc42d7662f3/lib/devise/rails/warden_compat.rb:43:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/failsafe.rb:26:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/lock.rb:11:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/lock.rb:11:in synchronize' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/lock.rb:11:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:106:in call' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/rack/request_handler.rb:96:in process_request' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:513:in accept_and_process_next_request' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:274:in main_loop' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:321:in start_request_handler' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in send' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in handle_spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:479:in safe_fork' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:270:in handle_spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in send ' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in server_main_loop' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in start_synchronously' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusi on_passenger/abstract_server.rb:180:in start' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:149:in start' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:219:in spawn_rails_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:132:in lookup_or_add' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:214:in spawn_rails_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:82:in synchronize' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:79:in synchronize' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:213:in spawn_rails_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:132:in spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:275:in spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:275:in handle_spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in __send__' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in server_main_loop' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/helper-scripts/passenger-spawn-server:99

My guess without seeing the stack trace is that Sphinx's searchd and indexer command-line tools aren't accessible directly by cron (they're in your PATH, but not cron's). Thus, Thinking Sphinx is presuming an older version of Sphinx and sending/expecting a slightly different protocol. Although the fact that it's making progress on this front is odd... perhaps you have two different versions of Sphinx installed?

You can set the Sphinx version manually in your config/sphinx.yml file:

production:
  version: 2.0.8

Also setting the SPHINX_VERSION environment variable will have the same affect.

Unrelated, but there's no need to rebuild on a regular basis - just running an index ensures the data Sphinx has loaded is up to date. A rebuild is only required when you're changing your index definitions (much like a db:migrate call).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM