Unicorn with Ruby 2.4.1 导致奇怪的崩溃 [英] Unicorn with Ruby 2.4.1 causing weird crash

查看:33
本文介绍了Unicorn with Ruby 2.4.1 导致奇怪的崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 Ruby 2.3.1 升级到 Ruby 2.4.1,这样做后 Unicorn 似乎与新版本不兼容.我收到以下错误.我正在使用 Unicorn 5.1.0 并尝试过 Unicorn 5.3.1 无济于事.我是否需要使用不同的库而不是 XCode 工具进行编译?

I am upgrading from Ruby 2.3.1 to Ruby 2.4.1 and upon doing so Unicorn seems be incompatible with the new version. I get the errors below. I am using Unicorn 5.1.0 and have tried Unicorn 5.3.1 to no avail. Do I need to compile with a different lib instead of XCode Tools?

我在使用 foreman start 和 Procfile 启动服务器后立即收到错误:

I get the error immediately upon starting the server with foreman start and the Procfile:

webpack: bin/webpack-dev-server
gulp: gulp
redis: ./scripts/start_redis_server.sh
sidekiq: bundle exec sidekiq -C config/sidekiq.yml
annotations_server: ./scripts/start_annotation_server.sh
rails: bundle exec unicorn_rails -p 3000 -c config/unicorn.rb

如果我使用一个简单的 bin/rails s,它似乎可以正常启动和运行,这就是为什么我认为它是 Unicorn 特有的.

It seems to start and run fine if I use a simple bin/rails s which I why I think it is specific to Unicorn.

objc[40847]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called.
objc[40846]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called.
objc[40846]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
objc[40847]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
E, [2017-10-05T12:12:01.618013 #40833] ERROR -- : reaped #<Process::Status: pid 40847 SIGABRT (signal 6)> worker=1
E, [2017-10-05T12:12:01.618064 #40833] ERROR -- : reaped #<Process::Status: pid 40846 SIGABRT (signal 6)> worker=0
I, [2017-10-05T12:12:01.619387 #40850]  INFO -- : Refreshing Gem list
I, [2017-10-05T12:12:01.620867 #40851]  INFO -- : Refreshing Gem list

推荐答案

MacOS High Sierra 更改了 fork 系统调用 的行为,以便在分叉进程中调用 Objective-C API 被视为错误.

MacOS High Sierra changed the behaviour of the fork syscall such that calls to Objective-C APIs in forked processes are treated as errors.

在 macOS High Sierra 上使用 Ruby 时,这是 Ruby 使用的.同样的问题也会影响 Puma 和其他使用多进程模型的服务器,因此严格来说不是 Unicorn(或 Puma)问题,而是 Ruby 问题之一.

When using Ruby on macOS High Sierra, this is what is used By Ruby. The same issue also affects Puma and other servers using a multi-process model and is thus not strictly a Unicorn (or Puma) issue, but one of Ruby.

该问题已在 Unicorn 邮件列表 和关于 Puma 问题.

The issue was discussed on the Unicorn mailing list and on a Puma issue.

如果您出于任何原因需要坚持使用旧的 Ruby 版本,作为一种变通方法,您可以在开始 Ruby 进程之前添加以下环境变量:

If you need to stick to your old Ruby version for any reason, as a workaround, you can add the following environment variable before starting the Ruby process:

OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

最好更新到 Ruby 2.4.4 或更高版本(包括 2.5 和 2.6).这些版本包括此问题的修复 Ruby 本身,您不需要再设置环境变量.

Preferably, you should update to Ruby 2.4.4 or higher (including 2.5 and 2.6). These versions include the fix for this issue in Ruby itself and you don't need to set the environment variable anymore.

这篇关于Unicorn with Ruby 2.4.1 导致奇怪的崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆