加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 思考Sphinx索引在命令行上成功,但在Cron作业中

发布时间:2020-12-17 02:58:52 所属栏目:百科 来源:网络整理
导读:我承认我已经在Ubuntu上拼凑了一个大部分正在运行的制作设置,其中Capistrano来自官方文档(看起来过时且做了很多假设)和各种过时的博客文章.无论如何,最后一个烦人的挂断是当我手工完成索引时(并且在部署时我非常肯定),但是Cron无法工作. 这是我的crontab: $
我承认我已经在Ubuntu上拼凑了一个大部分正在运行的制作设置,其中Capistrano来自官方文档(看起来过时且做了很多假设)和各种过时的博客文章.无论如何,最后一个烦人的挂断是当我手工完成索引时(并且在部署时我非常肯定),但是Cron无法工作.

这是我的crontab:

$crontab -l
# m h  dom mon dow   command
* * * * * cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index >> /var/www/app/current/log/cron.log 2>&1

这是日志输出(这实际上每次调用出现3次):

Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
  * bin_path
  * searchd_binary_name
  * indexer_binary_name

For more information,read the documentation:
http://freelancing-god.github.com/ts/en/advanced_config.html

这是当我手动运行相同的命令时(也可以在记录时运行):

$cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index
(in /var/www/app/releases/20100729042739)
Generating Configuration to /var/www/app/releases/20100729042739/config/production.sphinx.conf
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009,Andrew Aksyonoff

using config file '/var/www/app/releases/20100729042739/config/production.sphinx.conf'...
indexing index 'app_core'...
collected 5218 docs,3.9 MB
collected 5218 attr values
sorted 0.0 Mvalues,100.0% done
sorted 0.7 Mhits,100.0% done
total 5218 docs,3898744 bytes
total 0.616 sec,6328760 bytes/sec,8470.28 docs/sec
distributed index 'app' can not be directly indexed; skipping.
total 3 reads,0.008 sec,1110.2 kb/call avg,2.6 msec/call avg
total 15 writes,0.016 sec,540.4 kb/call avg,1.0 msec/call avg
rotating indices: succesfully sent SIGHUP to searchd (pid=20101).

也相关:

$which rake        
/usr/local/bin/rake
$which indexer
/usr/local/bin/indexer

这个错误有些常见,但它很有趣,它在命令行中工作得很好,我怀疑其他的东西很奇怪.我还有另外两个任务关键型的cron作业,这些作业运行的rake任务看起来完全相同并且运行良好,不确定这个有什么不同.任何帮助将不胜感激!

PS-目前的Capistrano和TS版本是否有权威的部署配置?似乎每个人都自己动手,官方文档似乎与博客帖子一样特殊.

解决方法

当您手动运行时,crontab是否与您登录的用户拥有相同的用户?

由于它似乎是一个明确的PATH问题,并且cron运行受限制的PATH(即不是你的.profile中的内容),请尝试将其添加到crontab文件的顶部.

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

或者,如果您不想修改cron的PATH,可以将所需的文件符号链接到/usr/sbin,默认情况下可能在PATH中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读