私は、公式ドキュメント (時代遅れであり、多くの仮定を行っているようです) とさまざまな時代遅れのさまざまなブログ投稿から、Capistrano を使用して Ubuntu でほとんど機能する実稼働セットアップをまとめたことを認めます。とにかく、最後の厄介なハングアップは、手動で行うとインデックス作成が機能することです (そして、デプロイ時にはかなり確信があります) が、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
エラーはやや一般的ですが、コマンドラインから正常に動作するのは変なにおいがします。何か他のものがおかしいのではないかと思います。他に 2 つのミッション クリティカルな cron ジョブがあり、rake タスクを実行しますが、これらはまったく同じように見えて正常に実行されますが、これについて何が違うのかわかりません。どんな助けでも大歓迎です!
PS-現在の Capistrano および TS バージョンで、これに対する正式なデプロイ構成はありますか? 誰もが独自に開発しているようで、公式ドキュメントはブログの投稿と同じくらい特異なようです。