【问题标题】:How to get sphinx (search) gem working in a PaaS such as heroku如何让 sphinx(搜索)gem 在诸如 heroku 这样的 PaaS 中工作
【发布时间】:2019-02-22 01:10:09
【问题描述】:

部署使用 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

【问题讨论】:

    标签: ruby-on-rails heroku thinking-sphinx


    【解决方案1】:

    默认情况下,Sphinx 不会在 Flying Sphinx 上运行 - 就像在本地计算机上一样,您需要运行相关的 ts:... rake 任务。 ts:rebuild 应该处理所有事情,但是如果您想更具体地完成每个步骤:

    • ts:configure 将生成配置文件(在 Heroku 上,将其发送到 Flying Sphinx 服务器)。
    • ts:start 将启动守护进程。
    • ts:index 将处理您的所有索引。

    如果您使用 SQL 支持的索引,您应该在开始之前运行索引任务,但对于实时索引,它的顺序是上面列出的。重建任务以适当的顺序处理所有这些。

    只要您使用thinking-sphinx gem 的v4 和flying-sphinx gem 的v2,这些任务将在本地和Heroku 上正确运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-01
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      • 2011-08-21
      • 1970-01-01
      • 1970-01-01
      • 2016-03-03
      相关资源
      最近更新 更多