about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorStephen Demjanenko <sdemjanenko@gmail.com>2019-05-03 15:20:18 -0700
committerEric Wong <e@80x24.org>2019-05-03 22:24:32 +0000
commit5c613c6ea98541df587193e861364c858a8a0abd (patch)
treee66f9e55e9c23c89caa8d78fd94d5ba3ea7adac5 /lib
parentfa558053ab0cc9ddc8316b4be1c580a7b29e5c20 (diff)
downloadunicorn-5c613c6ea98541df587193e861364c858a8a0abd.tar.gz
When running: ```
require 'kgio'
require 'raindrops'

F_SETPIPE_SZ = 1031 if RUBY_PLATFORM =~ /linux/

Kgio::Pipe.new.each do |io|
  io.close_on_exec = true
  if defined?(F_SETPIPE_SZ)
    begin
      puts "setting"
      io.fcntl(F_SETPIPE_SZ, Raindrops::PAGE_SIZE)
    rescue Errno::EINVAL
      puts "rescued"
    rescue => e
      puts ["FAILED HARD", e].inspect
    end
  end
end
```
on a few servers to test some Unicorn boot failures I saw:
```
["FAILED HARD", #<Errno::EPERM: Operation not permitted>]
```

The `EPERM` error gets raised by the Linux kernel if:
```
(too_many_pipe_buffers_hard(pipe->user) ||
too_many_pipe_buffers_soft(pipe->user)) &&
!capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)
```

Given that the resize is not strictly necessary Unicorn should
rescue the error and continue booting.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 5f2134d..dd5dff4 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -123,6 +123,9 @@ module Unicorn
           io.fcntl(F_SETPIPE_SZ, Raindrops::PAGE_SIZE)
         rescue Errno::EINVAL
           # old kernel
+        rescue Errno::EPERM
+          # resizes fail if Linux is close to the pipe limit for the user
+          # or if the user does not have permissions to resize
         end
       end
     end