Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Unicorn loads empty pages #298

Closed
shilov opened this Issue Jul 16, 2011 · 4 comments

Comments

Projects
None yet
3 participants

shilov commented Jul 16, 2011

Banging my head against the desk trying to figure out why Unicorn loads blank pages, meanwhile, WEBrick loads everything just fine with no problems whatsoever.

The pages take forever to load and when they do, there is no content and nothing in the source.

The development log shows no errors:

Started GET "/admin" for 192.168.1.105 at Fri Jul 15 20:48:41 -0700 2011
 Processing by Admin::DashboardController#index as HTML
 AdminUser Load (0.2ms)  SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 1 LIMIT 1
Rendered /home/shilov/.rvm/gems/ruby-1.8.7-p334/bundler/gems/active_admin-4a6a8fe7f683/app/views/active_admin/dashboard/index.html.arb (4.6ms)
Completed 200 OK in 38ms (Views: 9.8ms | ActiveRecord: 2.1ms)

My Unicorn config:

worker_processes 4

working_directory "/myproject/"

listen "/tmp/.sock", :backlog => 64
listen 8080, :tcp_nopush => false

timeout 30

stderr_path "/myproject/log/unicorn.stderr.log"
stdout_path "/myproject/log/unicorn.stdout.log"

preload_app(true)

pid "/myproject/tmp/pids/unicorn.pid"

before_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!

  old_pid = Rails.root + '/tmp/pids/unicorn.pid.oldbin'
  if File.exists?(old_pid) && server.pid != old_pid
    begin
      Process.kill("QUIT", File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
      # someone else did our job for us
    end
  end
end

after_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
  Bundler.setup
end

Other pages outside of the ActiveAdmin scope load just fine and include ActiveAdmin styling, but anything within /admin shows empty pages.

I'm running Rails 3.1.0 rc4 and Ruby 1.8.7

shilov commented Jul 17, 2011

Switching from using unicorn to using unicorn_rails to start the project seems to have fixed the issue. No idea why this worked.

Additionally, I was also able to get it working with unicorn but the environment set to production instead of development (development always returned the blank page).

I'm guessing this has something to do with Rack since that seems to be the only difference between unicorn_rails and unicorn -E production vs unicorn -E development

@shilov shilov closed this Jul 17, 2011

I am seeing this with activeadmin 0.4.4 and unicorn (and unicorn_rails) 4.3.1, very vanilla setup in development. Empty pages with unicorn, works with webrick.

this is the fix and needs to be merged: gregbell#1403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment