gpt4 book ai didi

ruby - unicorn 与 Ruby 2.4.1 导致奇怪的崩溃

转载 作者:数据小太阳 更新时间:2023-10-29 06:55:57 26 4
gpt4 key购买 nike

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

我在使用 foreman start 和 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 特有的。

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 changed the behaviour of the fork syscall这样在 fork 进程中对 Objective-C API 的调用将被视为错误。

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

这个问题在 Unicorn mailing list 上讨论过在 Puma issue 上.

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

OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

您最好更新到 Ruby 2.4.4 或更高版本(包括 2.5 和 2.6)。这些版本包括 the fix对于 Ruby 本身的这个问题,你不需要再设置环境变量。

关于ruby - unicorn 与 Ruby 2.4.1 导致奇怪的崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46591470/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com