From d9927162a3f17f025bad593fc7a7a1b253719244 Mon Sep 17 00:00:00 2001 From: "Jacob Vosmaer (GitLab)" Date: Tue, 23 Jan 2018 13:32:15 +0000 Subject: [PATCH] Prevent Unicorn crashing in development on macOS --- config/unicorn.rb.example.development | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/unicorn.rb.example.development b/config/unicorn.rb.example.development index 3cd00d53a15..0df028648d1 100644 --- a/config/unicorn.rb.example.development +++ b/config/unicorn.rb.example.development @@ -1,2 +1,15 @@ worker_processes 2 timeout 60 + +before_fork do |server, worker| + if /darwin/ =~ RUBY_PLATFORM + require 'fiddle' + + # Dynamically load Foundation.framework, ~implicitly~ initialising + # the Objective-C runtime before any forking happens in Unicorn + # + # From https://bugs.ruby-lang.org/issues/14009 + Fiddle.dlopen '/System/Library/Frameworks/Foundation.framework/Foundation' + end +end +