2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

unicorn-worker-killer の設定例

Last updated at Posted at 2018-01-10

Gemfile

gem 'unicorn-worker-killer' を追記して bundle install

設定例

config.ru
require 'unicorn/worker_killer'
use Unicorn::WorkerKiller::MaxRequests, 3072, 4096, true #ワーカーが処理したリクエストの数に基づいて、Unicornワーカーを自動的に再起動します。 trueオプションでunicorn.stderr.logにログを出力します。
use Unicorn::WorkerKiller::Oom, (192*(1024**2)), (256*(1024**2)) # メモリサイズに基づいてUnicornワーカーを自動的に再起動します。


require ::File.expand_path('../config/environment', __FILE__) # この記述の上に書くこと!
run Rails.application

こんなログが出ます

INFO -- : #<Unicorn::HttpServer:0x0055ad705e4c78>: worker (pid: 3057) has 1 left before being killed
WARN -- : #<Unicorn::HttpServer:0x0055ad705e4c78>: worker (pid: 3057) exceeds max number of requests (limit: 10)
WARN -- : Unicorn::WorkerKiller send SIGQUIT (pid: 3057) alive: 213 sec (trial 1)
INFO -- : reaped #<Process::Status: pid 3057 exit 0> worker=3
INFO -- : worker=3 ready

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?