File: unicorn.eye

package info (click to toggle)
ruby-eye 0.7-5.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 672 kB
  • sloc: ruby: 5,003; makefile: 3
file content (39 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Example: how to run unicorn, and monitor its child processes

RUBY = '/usr/local/ruby/1.9.3/bin/ruby' # ruby on the server
RAILS_ENV = 'production'

Eye.application "rails_unicorn" do
  env "RAILS_ENV" => RAILS_ENV

  # unicorn requires to be `ruby` in path (for soft restart)
  env "PATH" => "#{File.dirname(RUBY)}:#{ENV['PATH']}"

  working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ processes ]))

  process("unicorn") do
    pid_file "tmp/pids/unicorn.pid"
    start_command "#{RUBY} ./bin/unicorn -Dc ./config/unicorn.rb -E #{RAILS_ENV}"
    stdall "log/unicorn.log"

    # stop signals:
    # http://unicorn.bogomips.org/SIGNALS.html
    stop_signals [:TERM, 10.seconds]

    # soft restart
    restart_command "kill -USR2 {PID}"

    check :cpu, :every => 30, :below => 80, :times => 3
    check :memory, :every => 30, :below => 150.megabytes, :times => [3,5]

    start_timeout 100.seconds
    restart_grace 30.seconds

    monitor_children do
      stop_command "kill -QUIT {PID}"
      check :cpu, :every => 30, :below => 80, :times => 3
      check :memory, :every => 30, :below => 150.megabytes, :times => [3,5]
    end
  end

end