草庐IT

ruby-on-rails-4 - Rails 4.2:sidekiq 无法连接到 Redis(Errno::ECONNREFUSED),由 foreman 启动

coder 2023-11-08 原文

在本地主机上的开发模式下(OS X°我开始使用

foreman start

我的 Procfile 是: postgresql: postgres -D 供应商/postgresql redis: redis 服务器供应商/redis/db/redis.conf redis-slave:redis-server vendor/redis-slave/db/redis.conf sidekiq: sidekiq -C config/sidekiq.yml -q devise,1 -q default -q mailers sidekiq_web: thin -R sidekiq.ru start -p 9292 邮件:mailcatcher -f 网络:bundle exec unicorn -p 3001 -c ./config/unicorn.rb rails: bundle exec rails s unicorn

一切正常,但 sidekiq 无法连接到正在运行的 Redis 实例,因此它退出并返回代码 但是,如果我在不同的窗口中启动每个进程,它运行良好......我的工头脚本可能有什么问题?

         $ foreman start
        01:19:21 postgresql.1  | started with pid 48166
        01:19:21 redis.1       | started with pid 48167
        01:19:21 redis-slave.1 | started with pid 48168
        01:19:21 sidekiq.1     | started with pid 48169
        01:19:21 sidekiq_web.1 | started with pid 48170
        01:19:21 mail.1        | started with pid 48171
        01:19:21 web.1         | started with pid 48172
        01:19:21 rails.1       | started with pid 48173
        01:19:21 redis-slave.1 | 48168:S 16 Aug 01:19:21.220 * Increased maximum number of open files to 10032 (it was originally set to 2560).
        01:19:21 redis-slave.1 |                 _._
        01:19:21 redis-slave.1 |            _.-``__ ''-._
        01:19:21 redis-slave.1 |       _.-``    `.  `_.  ''-._           Redis 3.0.1 (00000000/0) 64 bit
        01:19:21 redis-slave.1 |   .-`` .-```.  ```\/    _.,_ ''-._
        01:19:21 redis-slave.1 |  (    '      ,       .-`  | `,    )     Running in standalone mode
        01:19:21 redis-slave.1 |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6380
        01:19:21 redis-slave.1 |  |    `-._   `._    /     _.-'    |     PID: 48168
        01:19:21 redis-slave.1 |   `-._    `-._  `-./  _.-'    _.-'
        01:19:21 redis-slave.1 |  |`-._`-._    `-.__.-'    _.-'_.-'|
        01:19:21 redis-slave.1 |  |    `-._`-._        _.-'_.-'    |           http://redis.io
        01:19:21 redis-slave.1 |   `-._    `-._`-.__.-'_.-'    _.-'
        01:19:21 redis-slave.1 |  |`-._`-._    `-.__.-'    _.-'_.-'|
        01:19:21 redis-slave.1 |  |    `-._`-._        _.-'_.-'    |
        01:19:21 redis-slave.1 |   `-._    `-._`-.__.-'_.-'    _.-'
        01:19:21 redis-slave.1 |       `-._    `-.__.-'    _.-'
        01:19:21 redis-slave.1 |           `-._        _.-'
        01:19:21 redis-slave.1 |               `-.__.-'
        01:19:21 redis-slave.1 |
        01:19:21 redis-slave.1 | 48168:S 16 Aug 01:19:21.248 # Server started, Redis version 3.0.1
        01:19:21 redis-slave.1 | 48168:S 16 Aug 01:19:21.275 * DB loaded from disk: 0.028 seconds
        01:19:21 redis-slave.1 | 48168:S 16 Aug 01:19:21.275 * The server is now ready to accept connections on port 6380
        01:19:21 postgresql.1  | LOG:  database system was shut down at 2015-08-16 01:12:29 CEST
        01:19:21 postgresql.1  | LOG:  database system is ready to accept connections
        01:19:21 postgresql.1  | LOG:  autovacuum launcher started
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.254 * Connecting to MASTER localhost:6379
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.255 * MASTER <-> SLAVE sync started
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.255 * Non blocking connect for SYNC fired the event.
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.256 * Master replied to PING, replication can continue...
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.256 * Partial resynchronization not possible (no cached master)
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.268 * Full resync from master: 337a934fccebc3e0ad1627e6f06f0e061b0515e2:1
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.374 * MASTER <-> SLAVE sync: receiving 18 bytes from master
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.374 * MASTER <-> SLAVE sync: Flushing old data
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.374 * MASTER <-> SLAVE sync: Loading DB in memory
        01:19:22 redis-slave.1 | 48168:S 16 Aug 01:19:22.378 * MASTER <-> SLAVE sync: Finished with success
        01:19:23 sidekiq_web.1 | /Users/yves/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/backends/base.rb:103: warning: epoll is not supported on this platform
        01:19:23 sidekiq.1     | exited with code 0
        01:19:23 system        | sending SIGTERM to all processes
        01:19:23 postgresql.1  | LOG:  received smart shutdown request
        01:19:23 redis-slave.1 | 48168:signal-handler (1439680763) Received SIGTERM scheduling shutdown...
        01:19:23 postgresql.1  | LOG:  autovacuum launcher shutting down
        01:19:23 postgresql.1  | LOG:  shutting down
        01:19:23 redis.1       | exited with code 0
        01:19:23 redis-slave.1 | 48168:S 16 Aug 01:19:23.505 # Connection with master lost.
        01:19:23 redis-slave.1 | 48168:S 16 Aug 01:19:23.505 * Caching the disconnected master state.
        01:19:23 web.1         | terminated by SIGTERM
        01:19:23 mail.1        | terminated by SIGTERM
        01:19:23 rails.1       | terminated by SIGTERM
        01:19:23 sidekiq_web.1 | terminated by SIGTERM
        01:19:23 postgresql.1  | LOG:  database system is shut down
        01:19:23 postgresql.1  | exited with code 0
        01:19:23 redis-slave.1 | 48168:S 16 Aug 01:19:23.575 # User requested shutdown...
        01:19:23 redis-slave.1 | 48168:S 16 Aug 01:19:23.575 # Redis is now ready to exit, bye bye...
        01:19:23 redis-slave.1 | exited with code 0
        yves@MacMini: recommence $ ps aux | grep redis
        yves            48330   0.0  0.0  2441988    672 s000  S+    1:26AM   0:00.01 grep redis
        yves@MacMini: recommence $ foreman start
        01:26:26 postgresql.1  | started with pid 48353
        01:26:26 redis.1       | started with pid 48354
        01:26:26 redis-slave.1 | started with pid 48355
        01:26:26 sidekiq.1     | started with pid 48356
        01:26:26 sidekiq_web.1 | started with pid 48357
        01:26:26 mail.1        | started with pid 48358
        01:26:26 web.1         | started with pid 48359
        01:26:26 rails.1       | started with pid 48360
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.464 * Increased maximum number of open files to 10032 (it was originally set to 2560).
        01:26:26 redis-slave.1 |                 _._
        01:26:26 redis-slave.1 |            _.-``__ ''-._
        01:26:26 redis-slave.1 |       _.-``    `.  `_.  ''-._           Redis 3.0.1 (00000000/0) 64 bit
        01:26:26 redis-slave.1 |   .-`` .-```.  ```\/    _.,_ ''-._
        01:26:26 redis-slave.1 |  (    '      ,       .-`  | `,    )     Running in standalone mode
        01:26:26 redis-slave.1 |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6380
        01:26:26 redis-slave.1 |  |    `-._   `._    /     _.-'    |     PID: 48355
        01:26:26 redis-slave.1 |   `-._    `-._  `-./  _.-'    _.-'
        01:26:26 redis-slave.1 |  |`-._`-._    `-.__.-'    _.-'_.-'|
        01:26:26 redis-slave.1 |  |    `-._`-._        _.-'_.-'    |           http://redis.io
        01:26:26 redis-slave.1 |   `-._    `-._`-.__.-'_.-'    _.-'
        01:26:26 redis-slave.1 |  |`-._`-._    `-.__.-'    _.-'_.-'|
        01:26:26 redis-slave.1 |  |    `-._`-._        _.-'_.-'    |
        01:26:26 redis-slave.1 |   `-._    `-._`-.__.-'_.-'    _.-'
        01:26:26 redis-slave.1 |       `-._    `-.__.-'    _.-'
        01:26:26 redis-slave.1 |           `-._        _.-'
        01:26:26 redis-slave.1 |               `-.__.-'
        01:26:26 redis-slave.1 |
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.467 # Server started, Redis version 3.0.1
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.467 * DB loaded from disk: 0.000 seconds
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.467 * The server is now ready to accept connections on port 6380
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.469 * Connecting to MASTER localhost:6379
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.470 * MASTER <-> SLAVE sync started
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.470 * Non blocking connect for SYNC fired the event.
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.470 * Master replied to PING, replication can continue...
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.471 * Partial resynchronization not possible (no cached master)
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.471 * Full resync from master: f55a717fbd36511c5581e081e154c8e557499754:1
        01:26:26 postgresql.1  | LOG:  database system was shut down at 2015-08-16 01:19:23 CEST
        01:26:26 postgresql.1  | LOG:  autovacuum launcher started
        01:26:26 postgresql.1  | LOG:  database system is ready to accept connections
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.557 * MASTER <-> SLAVE sync: receiving 18 bytes from master
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.558 * MASTER <-> SLAVE sync: Flushing old data
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.558 * MASTER <-> SLAVE sync: Loading DB in memory
        01:26:26 redis-slave.1 | 48355:S 16 Aug 01:26:26.558 * MASTER <-> SLAVE sync: Finished with success
        01:26:27 sidekiq_web.1 | /Users/yves/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/backends/base.rb:103: warning: epoll is not supported on this platform
        01:26:27 sidekiq.1     | exited with code 0
        01:26:27 system        | sending SIGTERM to all processes
        01:26:27 postgresql.1  | LOG:  received smart shutdown request
        01:26:27 redis-slave.1 | 48355:signal-handler (1439681187) Received SIGTERM scheduling shutdown...
        01:26:27 postgresql.1  | LOG:  autovacuum launcher shutting down
        01:26:27 postgresql.1  | LOG:  shutting down
        01:26:27 postgresql.1  | LOG:  database system is shut down
        01:26:27 redis.1       | exited with code 0
        01:26:27 redis-slave.1 | 48355:S 16 Aug 01:26:27.991 # Connection with master lost.
        01:26:27 redis-slave.1 | 48355:S 16 Aug 01:26:27.991 * Caching the disconnected master state.
        01:26:27 redis-slave.1 | 48355:S 16 Aug 01:26:27.997 # User requested shutdown...
        01:26:27 redis-slave.1 | 48355:S 16 Aug 01:26:27.997 # Redis is now ready to exit, bye bye...
        01:26:27 redis-slave.1 | exited with code 0
        01:26:27 postgresql.1  | exited with code 0
        01:26:28 mail.1        | terminated by SIGTERM
        01:26:28 sidekiq_web.1 | terminated by SIGTERM
        01:26:28 rails.1       | terminated by SIGTERM
        01:26:28 web.1         | terminated by SIGTERM

sidekiq.log 显示错误..

        WARN: Unresolved specs during Gem::Specification.reset:
              minitest (~> 5.1)
        WARN: Clearing out unresolved specs.
        Please report a bug if this causes problems.
        2015-08-15T23:19:29.882Z 48183 TID-oxy6u8hqw INFO: Booting Sidekiq 3.4.2 with redis options {:url=>"redis://localhost:6379/0", :driver=>:hiredis}
        2015-08-15T23:19:32.130Z 48183 TID-oxy6u8hqw INFO: Running in ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
        2015-08-15T23:19:32.130Z 48183 TID-oxy6u8hqw INFO: See LICENSE and the LGPL-3.0 for licensing details.
        2015-08-15T23:19:32.130Z 48183 TID-oxy6u8hqw INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org/pro
        2015-08-15T23:19:32.235Z 48183 TID-oxy6qw1tk ERROR: Error fetching message: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)
        2015-08-15T23:19:32.235Z 48183 TID-oxy6qw1tk ERROR: /Users/yves/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/redis-3.2.1/lib/redis/client.rb:331:in `rescue in establish_connection'

最佳答案

尝试使用“127.0.0.1”或“::1”代替“localhost”。 IPv6 与 IPv4 有时会很棘手。

关于ruby-on-rails-4 - Rails 4.2:sidekiq 无法连接到 Redis(Errno::ECONNREFUSED),由 foreman 启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32030477/

有关ruby-on-rails-4 - Rails 4.2:sidekiq 无法连接到 Redis(Errno::ECONNREFUSED),由 foreman 启动的更多相关文章

  1. ruby-on-rails - 使用 Ruby on Rails 进行自动化测试 - 最佳实践 - 2

    很好奇,就使用ruby​​onrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提

  2. ruby-on-rails - rails : keeping DRY with ActiveRecord models that share similar complex attributes - 2

    这似乎应该有一个直截了当的答案,但在Google上花了很多时间,所以我找不到它。这可能是缺少正确关键字的情况。在我的RoR应用程序中,我有几个模型共享一种特定类型的字符串属性,该属性具有特殊验证和其他功能。我能想到的最接近的类似示例是表示URL的字符串。这会导致模型中出现大量重复(甚至单元测试中会出现更多重复),但我不确定如何让它更DRY。我能想到几个可能的方向...按照“validates_url_format_of”插件,但这只会让验证干给这个特殊的字符串它自己的模型,但这看起来很像重溶液为这个特殊的字符串创建一个ruby​​类,但是我如何得到ActiveRecord关联这个类模型

  3. ruby-on-rails - 在 Rails 中将文件大小字符串转换为等效千字节 - 2

    我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,

  4. ruby-on-rails - Ruby net/ldap 模块中的内存泄漏 - 2

    作为我的Rails应用程序的一部分,我编写了一个小导入程序,它从我们的LDAP系统中吸取数据并将其塞入一个用户表中。不幸的是,与LDAP相关的代码在遍历我们的32K用户时泄漏了大量内存,我一直无法弄清楚如何解决这个问题。这个问题似乎在某种程度上与LDAP库有关,因为当我删除对LDAP内容的调用时,内存使用情况会很好地稳定下来。此外,不断增加的对象是Net::BER::BerIdentifiedString和Net::BER::BerIdentifiedArray,它们都是LDAP库的一部分。当我运行导入时,内存使用量最终达到超过1GB的峰值。如果问题存在,我需要找到一些方法来更正我的代

  5. ruby-on-rails - unicode 字符串的长度 - 2

    在我的Rails(2.3,Ruby1.8.7)应用程序中,我需要将字符串截断到一定长度。该字符串是unicode,在控制台中运行测试时,例如'א'.length,我意识到返回了双倍长度。我想要一个与编码无关的长度,以便对unicode字符串或latin1编码字符串进行相同的截断。我已经了解了Ruby的大部分unicode资料,但仍然有些一头雾水。应该如何解决这个问题? 最佳答案 Rails有一个返回多字节字符的mb_chars方法。试试unicode_string.mb_chars.slice(0,50)

  6. ruby-on-rails - Ruby on Rails 迁移,将表更改为 MyISAM - 2

    如何正确创建Rails迁移,以便将表更改为MySQL中的MyISAM?目前是InnoDB。运行原始执行语句会更改表,但它不会更新db/schema.rb,因此当在测试环境中重新创建表时,它会返回到InnoDB并且我的全文搜索失败。我如何着手更改/添加迁移,以便将现有表修改为MyISAM并更新schema.rb,以便我的数据库和相应的测试数据库得到相应更新? 最佳答案 我没有找到执行此操作的好方法。您可以像有人建议的那样更改您的schema.rb,然后运行:rakedb:schema:load,但是,这将覆盖您的数据。我的做法是(假设

  7. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  8. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  9. ruby-on-rails - Rails 3 中的多个路由文件 - 2

    Rails2.3可以选择随时使用RouteSet#add_configuration_file添加更多路由。是否可以在Rails3项目中做同样的事情? 最佳答案 在config/application.rb中:config.paths.config.routes在Rails3.2(也可能是Rails3.1)中,使用:config.paths["config/routes"] 关于ruby-on-rails-Rails3中的多个路由文件,我们在StackOverflow上找到一个类似的问题

  10. ruby-on-rails - 如何验证 update_all 是否实际在 Rails 中更新 - 2

    给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru

随机推荐