Note that there are some explanatory texts on larger screens.

plurals
  1. POUnicorn acting up on EC2
    primarykey
    data
    text
    <p>I have a medium EC2 instance which seems to corrupt unicorn instances after a few days, causing the application to throw 403 errors with urls showing as <code>http://app/foo/bar</code></p> <p>"app" is the proxy to unicorn. Here is my site config for nginx</p> <pre><code> upstream app { server unix:/home/foo/app/shared/sockets/unicorn.sock fail_timeout=0; } server { listen 80; # This is on by default. client_max_body_size 2G; # upload_max_file_size 50m; server_name foo.tld; # Hostname keepalive_timeout 5; root /home/foo/app/current/public; # Application root. access_log /home/foo/log/foo_access.log; # Logs for nginx access error_log /home/foo/log/foo_error.log; if ($request_method !~ ^(GET|HEAD|PUT|POST|DELETE|OPTIONS)$) { return 405; } if (-f $document_root/system/maintenance.html) { return 503; } error_page 503 @maintenance; location @maintenance { rewrite ^(.*)$ /system/maintenance.html last; break; } # Static serving as defined in the RoR guides # http://guides.rubyonrails.org/asset_pipeline.html#in-production location ~ ^/(assets(?!\/(files|pictures)))/ { gzip_static on; expires max; add_header Cache-Control public; } # Proxy forwarding to unicorn location / { try_files $uri/index.html $uri.html $uri @app; error_page 404 /404.html; error_page 422 /422.html; error_page 500 502 503 504 /500.html; error_page 403 /403.html; } location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app; } location = /favicon.ico { expires max; add_header Cache-Control public; } location ~ \.php { deny all; } } </code></pre> <p>My unicorn.rb</p> <pre><code>worker_processes 4 working_directory '/home/foo/app/current' # This loads the application in the master process before forking # worker processes # Read more about it here: # http://unicorn.bogomips.org/Unicorn/Configurator.html preload_app true GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true timeout 30 # This is where we specify the socket. # We will point the upstream Nginx module to this socket later on listen '/home/foo/app/shared/sockets/unicorn.sock', :backlog =&gt; 64 pid '/home/foo/app/shared/pids/unicorn.pid' # Set the path of the log files inside the log folder of the testapp stderr_path '/home/foo/app/current/log/unicorn.stderr.log' stdout_path '/home/foo/app/current/log/unicorn.stdout.log' </code></pre> <p>And my cap recipe</p> <pre><code>require 'bundler/capistrano' set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system require "rvm/capistrano" # Load RVM's capistrano plugin. # Application name set :application, "foo" # Repo information set :repository, "foo.git" set :scm, :git set :branch, "master" # Server information set :user, "foo" set :scm_passphrase, "foo" set :deploy_via, :remote_cache server "foo.tld", :web, :app, :db # This is our EC2 Instance set :deploy_to, "/home/foo/app" ssh_options[:keys] = [File.join(ENV["HOME"], "keys/foo")] set :use_sudo, false namespace :deploy do desc "Restart of Unicorn" task :restart, :excerpt =&gt; { :no_release =&gt; true } do run "kill -a USR2 `cat /home/foo/app/shared/pids/unicorn.pid`" end desc "Start Unicorn" task :start, :excerpt =&gt; { :no_release =&gt; true } do run "cd #{current_path} ; bundle exec unicorn_rails -c config/unicorn.rb -E production -D" end desc "Stop Unicorn" task :stop, :excerpt =&gt; { :no_release =&gt; true } do run "kill -s QUIT `cat /home/foo/app/shared/pids/unicorn.pid`" end namespace :web do desc "Throw maintenance page up" task :disable do require "erb" on_rollback { run "rm #{shared_path}/system/maintenance.html" } reason = ENV['REASON'] deadline = ENV['UNTIL'] template = File.read("./app/views/layouts/maintenance.html.erb") result = ERB.new(template).result(binding) put result, "#{shared_path}/system/maintenance.html", :mode =&gt; 0644 end end end </code></pre> <p>Any insight as to why unicorn would act up after a few days? Additionally is there any "gotchas" in my current setup.?</p> <p>UPDATE: It looks like unicorn is never able to restart hung up processes</p> <pre><code>E, [2012-07-03T09:59:13.554781 #9521] ERROR -- : worker=3 PID:9656 timeout (31s &gt; 30s), killing E, [2012-07-03T09:59:13.710103 #9521] ERROR -- : reaped #&lt;Process::Status: pid 9656 SIGKILL (signal 9)&gt; worker=3 I, [2012-07-03T09:59:13.710349 #9521] INFO -- : worker=3 spawning... I, [2012-07-03T09:59:13.906277 #16214] INFO -- : worker=3 spawned pid=16214 I, [2012-07-03T09:59:13.906672 #16214] INFO -- : worker=3 ready E, [2012-07-03T13:37:45.158213 #9521] ERROR -- : worker=3 PID:16214 timeout (31s &gt; 30s), killing E, [2012-07-03T13:37:45.402827 #9521] ERROR -- : reaped #&lt;Process::Status: pid 16214 SIGKILL (signal 9)&gt; worker=3 I, [2012-07-03T13:37:45.403125 #9521] INFO -- : worker=3 spawning... I, [2012-07-03T13:37:45.531584 #16270] INFO -- : worker=3 spawned pid=16270 I, [2012-07-03T13:37:45.531982 #16270] INFO -- : worker=3 ready </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload