Ruby on rails 当我尝试重新编制索引时,是否考虑了斯芬克斯错误?

Ruby on rails 当我尝试重新编制索引时,是否考虑了斯芬克斯错误?,ruby-on-rails,ruby-on-rails-3,crontab,thinking-sphinx,Ruby On Rails,Ruby On Rails 3,Crontab,Thinking Sphinx,好的,我们的服务器上有一个rails应用程序,我已经安装了。每天早上12:30,我运行一个cron作业,截断帐户和联系人表并重新插入它们……这是我的cron 30 0 * * * /bin/bash -l -c 'cd /var/www/active && script/rails runner -e production '\''Account.db_insert'\$ 34 0 * * * /bin/bash -l -c 'cd /var/www/active &&a

好的,我们的服务器上有一个rails应用程序,我已经安装了。每天早上12:30,我运行一个cron作业,截断帐户和联系人表并重新插入它们……这是我的cron

30 0 * * * /bin/bash -l -c 'cd /var/www/active && script/rails runner -e production '\''Account.db_insert'\$
34 0 * * * /bin/bash -l -c 'cd /var/www/active && RAILS_ENV=production bundle exec rake ts:index --silent'
34 0 * * * /bin/bash -l -c 'cd /var/www/active && RAILS_ENV=production bundle exec rake ts:restart --silent'
正如您所见,crons执行
Account.db_insert
重新插入联系人和帐户,但每天我都会收到一封有错误的电子邮件……以下是我最近收到的两封

昨天的错误

using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
FATAL: failed to lock /var/www/active/db/sphinx/production/contact_core.spl: Resource temporarily unavailable, will not index. Try --rotate option.
using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
collected 403 docs, 0.0 MB
sorted 0.1 Mhits, 100.0% done
ERROR: index 'contact_core': rename /var/www/active/db/sphinx/production/contact_core.tmp.spl to /var/www/active/db/sphinx/production/contact_core.new.spl failed: No such file or directory.
total 403 docs, 25092 bytes
total 0.069 sec, 361571 bytes/sec, 5807.16 docs/sec
distributed index 'contact' can not be directly indexed; skipping.
total 5 reads, 0.001 sec, 133.7 kb/call avg, 0.2 msec/call avg
total 10 writes, 0.012 sec, 177.8 kb/call avg, 1.2 msec/call avg
今天的错误

using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
FATAL: failed to lock /var/www/active/db/sphinx/production/contact_core.spl: Resource temporarily unavailable, will not index. Try --rotate option.
using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
collected 403 docs, 0.0 MB
sorted 0.1 Mhits, 100.0% done
ERROR: index 'contact_core': rename /var/www/active/db/sphinx/production/contact_core.tmp.spl to /var/www/active/db/sphinx/production/contact_core.new.spl failed: No such file or directory.
total 403 docs, 25092 bytes
total 0.069 sec, 361571 bytes/sec, 5807.16 docs/sec
distributed index 'contact' can not be directly indexed; skipping.
total 5 reads, 0.001 sec, 133.7 kb/call avg, 0.2 msec/call avg
total 10 writes, 0.012 sec, 177.8 kb/call avg, 1.2 msec/call avg
知道我做错了什么吗

更新

在建议运行之后

 /usr/local/bin/indexer --config /etc/sphinxsearch/sphinx.conf --all --rotate
我犯了这个错误

 using config file '/etc/sphinxsearch/sphinx.conf'...
 ERROR: unknown key name 'client_timeout' in /etc/sphinxsearch/sphinx.conf line 591 col 16.
 FATAL: failed to parse config file '/etc/sphinxsearch/sphinx.conf'.

如错误消息所示,您可能希望使用
--rotate
开关运行索引器

一、 同样,使用Thinking Sphinx,但发现直接使用Sphinx索引器更容易。我让斯芬克斯为我生成配置,然后我可以直接在我的cron中调用
searchd
indexer

*/30 * * * * /usr/local/bin/indexer --config /etc/sphinxsearch/sphinx.conf --all --rotate

我发现这比完成Rake任务更有帮助。此外因为不必加载整个Rails堆栈,所以速度要快得多。

这会取代两个34 0***/bin/bash-l-c'cd/var/www/active&&Rails\u ENV=production bundle exec rake ts:index--silent'34 0***/bin/bash-l-c'cd/var/www/active&&Rails\u ENV=production bundle exec rake ts:restart--silent'/usr/local/bin/indexer--config/etc/sphinxsearch/sphinx.conf--all--rotate因为两个思考sphinx rake任务在12:34运行您的sphinx配置与我的不同,它看起来像您的:
/var/www/active/config/production.sphinx.conf
。因此,相应地更新命令中的
--config
。您使用的配置路径不正确。用你的,不要盲目模仿别人的建议<代码>/usr/local/bin/indexer--config/var/www/active/config/production.sphinx.conf--all--rotate