在部署使用sphinx gem进行搜索的Rails 5应用程序后,出现此错误:
2019-02-22T01:05:28.930528+00:00 app[web.1]: D, [2019-02-22T01:05:28.930455 #4] DEBUG -- : [64986155-264b-42ae-a1ce-d2772cd3dc38] Sphinx Query (1.4ms) SELECT * FROM `article_core` WHERE MATCH('Figaro') AND `sphinx_deleted` = 0 LIMIT 0, 500
2019-02-22T01:05:28.930863+00:00 app[web.1]: I, [2019-02-22T01:05:28.930788 #4] INFO -- : [64986155-264b-42ae-a1ce-d2772cd3dc38] Completed 500 Internal Server Error in 97ms (ActiveRecord: 47.5ms)
2019-02-22T01:05:28.931739+00:00 app[web.1]: F, [2019-02-22T01:05:28.931653 #4] FATAL -- : [64986155-264b-42ae-a1ce-d2772cd3dc38]
2019-02-22T01:05:28.931841+00:00 app[web.1]: F, [2019-02-22T01:05:28.931771 #4] FATAL -- : [64986155-264b-42ae-a1ce-d2772cd3dc38] ThinkingSphinx::ConnectionError (Error connecting to Sphinx via the MySQL protocol. Can't connect to MySQL server on '127.0.0.1' (111)):
2019-02-22T01:05:28.931936+00:00 app[web.1]: F, [2019-02-22T01:05:28.931867 #4] FATAL -- : [64986155-264b-42ae-a1ce-d2772cd3dc38]
2019-02-22T01:05:28.932045+00:00 app[web.1]: F, [2019-02-22T01:05:28.931975 #4] FATAL -- : [64986155-264b-42ae-a1ce-d2772cd3dc38] app/controllers/articles_controller.rb:169:in `results'
如何克服这个错误?
更新:添加缺少的fly_sphinx宝石和'heroku'木制附件后, 我仍然得到:
FATAL -- : [e52202a5-b3fa-4b89-b188-e7e23c1cfc58] ThinkingSphinx::ConnectionError (Error connecting to Sphinx via the MySQL protocol. Lost connection to MySQL server at 'reading authorization packet', system error: 0):
UPDATE2:尝试启动命令后仍然没有运气:
heroku run rake ts:start; echo $?
› Warning: heroku update available from 7.18.9 to 7.21.0
Running rake ts:start on ⬢ dart-research-database... up, run.8944 (Hobby)
I, [2019-02-22T01:54:12.587534 #4] INFO -- : Executing Action: start
W, [2019-02-22T01:54:13.378618 #4] WARN -- : Action failed.
I, [2019-02-22T01:54:13.651615 #4] INFO -- : Action Finished: start
0
答案 0 :(得分:1)
Sphinx默认不在Flying Sphinx上运行-就像在本地计算机上一样,您需要运行相关的ts:...
瑞克任务。 ts:rebuild
应该照顾好一切,但是如果您想更具体地执行每个步骤,则:
ts:configure
将生成配置文件(并在Heroku上将其发送到Flying Sphinx服务器)。ts:start
将启动守护程序。ts:index
将处理您的所有索引。如果您使用的是基于SQL的索引,则应在开始之前运行索引任务,但对于实时索引,它按上面列出的顺序运行。重建任务将按照适当的顺序处理所有这些工作。
并且,如果您使用的是思维狮身人面像gem的v4和飞行的狮身人面像gem的v2,则这些任务将在本地和Heroku上正确运行。