unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
						download: 
* [ANN] unicorn 4.2.0 - minor fixes and improvements
@ 2012-01-28  9:25 Eric Wong
  0 siblings, 0 replies; 4+ results
From: Eric Wong @ 2012-01-28  9:25 UTC (permalink / raw)
  To: mongrel-unicorn

Changes:

The GPLv3 is now an option to the Unicorn license.  The existing GPLv2
and Ruby-only terms will always remain options, but the GPLv3 is
preferred.

Daemonization is correctly detected on all terminals for development
use (Brian P O'Rourke).

Unicorn::OobGC respects applications that disable GC entirely
during application dispatch (Yuichi Tateno).

Many test fixes for OpenBSD, which may help other *BSDs, too.
(Jeremy Evans).

There is now _optional_ SSL support (via the "kgio-monkey"
RubyGem).  On fast, secure LANs, SSL is only intended for
detecting data corruption that weak TCP checksums cannot detect.
Our SSL support is remains unaudited by security experts.

There are also some minor bugfixes and documentation
improvements.

Ruby 2.0.0dev also has a copy-on-write friendly GC which can save memory
when combined with "preload_app true", so if you're in the mood, start
testing Unicorn with the latest Ruby!

* http://unicorn.bogomips.org/
* mongrel-unicorn@rubyforge.org
* git://bogomips.org/unicorn.git
* http://unicorn.bogomips.org/NEWS.atom.xml
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[relevance 6%]

* RE: Unicorn_rails ignores USR2 signal
      [irrelevant]                 ` <20120320195748.GA1187@dcvr.yhbt.net>
@ 2012-03-30 22:16                   ` Yeung, Jeffrey
  0 siblings, 0 replies; 4+ results
From: Yeung, Jeffrey @ 2012-03-30 22:16 UTC (permalink / raw)
  To: Eric Wong, unicorn list

I have little to report, unfortunately.  I still have not identified what is trapping USR2 in my application, if something is indeed doing that.

I've attempted to do a bit more investigation work in my spare time this week, and the results are still rather mysterious.

First, I applied your patch to http_server.rb that you suggested in this thread back on March 9th (quoted below), which re-overrides the signal handlers in build_app!().  The patch did work.  Okay, that seems to reconfirm that the app is doing something with the USR2 signal handler...

Then I modified the master_siginit() method a bit further to provide more info:
  def master_siginit
    QUEUE_SIGS.each { |sig|
      old_handler = trap(sig) { SIG_QUEUE << sig; awaken_master }
      logger.info("old handler for #{sig.to_s}: #{old_handler.inspect}")
    }
    trap(:CHLD) { awaken_master }
  end

And the output was a bit surprising.  Here is the Unicorn stderr log when starting up the service.  master_siginit() is called twice, as expected...

I, [2012-03-30T14:57:51.301839 #15828]  INFO -- : listening on addr=0.0.0.0:8080 fd=3
I, [2012-03-30T14:57:51.302341 #15828]  INFO -- : old handler for WINCH: nil
I, [2012-03-30T14:57:51.302435 #15828]  INFO -- : old handler for QUIT: "DEFAULT"
I, [2012-03-30T14:57:51.302505 #15828]  INFO -- : old handler for INT: "DEFAULT"
I, [2012-03-30T14:57:51.302573 #15828]  INFO -- : old handler for TERM: "DEFAULT"
I, [2012-03-30T14:57:51.302641 #15828]  INFO -- : old handler for USR1: "DEFAULT"
I, [2012-03-30T14:57:51.302709 #15828]  INFO -- : old handler for USR2: "DEFAULT"
I, [2012-03-30T14:57:51.302786 #15828]  INFO -- : old handler for HUP: "DEFAULT"
I, [2012-03-30T14:57:51.302853 #15828]  INFO -- : old handler for TTIN: nil
I, [2012-03-30T14:57:51.302917 #15828]  INFO -- : old handler for TTOU: nil
I, [2012-03-30T14:57:51.303502 #15828]  INFO -- : Refreshing Gem list
old handler for WINCH: #<Proc:0x00000002d97488@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for QUIT: #<Proc:0x00000002d97098@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for INT: #<Proc:0x00000002d96c70@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for TERM: #<Proc:0x00000002d96848@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for USR1: #<Proc:0x00000002d96420@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for USR2: #<Proc:0x00000002d95ff8@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for HUP: #<Proc:0x00000002d95bd0@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for TTIN: #<Proc:0x00000002d957a8@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
old handler for TTOU: #<Proc:0x00000002d953b8@/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:745>
master process ready
worker=0 ready

Which to me, looks like the USR2 handler was unchanged in the second master_siginit() call.  Yet, if I remove that second master_siginit() call from there, USR2 ceases to work.  :S

-Jeff

-----Original Message-----
diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 7d2c623..1b9d693 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -128,8 +128,7 @@ class Unicorn::HttpServer
     # setup signal handlers before writing pid file in case people get
     # trigger happy and send signals as soon as the pid file exists.
     # Note that signals don't actually get handled until the #join method
-    QUEUE_SIGS.each { |sig| trap(sig) { SIG_QUEUE << sig; awaken_master } }
-    trap(:CHLD) { awaken_master }
+    master_siginit
     self.pid = config[:pid]
 
     self.master_pid = $$
@@ -689,6 +688,9 @@ class Unicorn::HttpServer
         Gem.refresh
       end
       self.app = app.call
+
+      # override signal handlers the app may have set
+      master_siginit if preload_app
     end
   end
 
@@ -736,4 +738,9 @@ class Unicorn::HttpServer
     config_listeners.each { |addr| listen(addr) }
     raise ArgumentError, "no listeners" if LISTENERS.empty?
   end
+
+  def master_siginit
+    QUEUE_SIGS.each { |sig| trap(sig) { SIG_QUEUE << sig; awaken_master } }
+    trap(:CHLD) { awaken_master }
+  end
 end
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[relevance 7%]

* Problem restarting Unicorn
@ 2012-04-05  7:21 Andrew Stewart
  2012-04-05 11:34 ` Michael Guterl
  0 siblings, 1 reply; 4+ results
From: Andrew Stewart @ 2012-04-05  7:21 UTC (permalink / raw)
  To: mongrel-unicorn

Hello,

I seem to be confused about how to restart Unicorn when deploying updates to a Rails app via Capistrano.

I just had a problem where a bundled gem wasn't being seen by the Unicorn processes, even though app code I introduced at the same time was being served by the Unicorn processes.  I had restarted Unicorn numerous times using `bundle exec cap deploy:restart` (see the code below), which I thought was the right way to do zero-downtime restarts, but my problem was only solved by doing a hard restart of Unicorn with `bundle exec cap deploy:hard_restart`.

With each "normal" restart I tailed the stderr log to check everything was ok; everything appeared fine, with gems refreshed etc.

Please could somebody explain what I'm doing wrong with my normal restarts?

config/deploy.rb:

    set :unicorn_config, "#{current_path}/config/unicorn.rb"
    set :unicorn_pid,    "#{shared_path}/pids/unicorn.pid"

    namespace :deploy do
      task :start, :roles => :app, :except => { :no_release => true } do
        run "cd #{current_path} && #{sudo_workaround} bundle exec unicorn -c #{unicorn_config} -E #{rails_env} -D"
      end
      task :stop, :roles => :app, :except => { :no_release => true } do
        run "#{sudo_workaround} kill -s QUIT `cat #{unicorn_pid}`"
      end
      task :hard_stop, :roles => :app, :except => { :no_release => true } do
        run "#{sudo_workaround} kill `cat #{unicorn_pid}`"
      end
      task :restart, :roles => :app, :except => { :no_release => true } do
        run "#{sudo_workaround} kill -s USR2 `cat #{unicorn_pid}`"
      end
      task :hard_restart, :roles => :app, :except => { :no_release => true } do
        hard_stop
        start
      end
    end
    
    # Works around Ubuntu changing the PATH when you use sudo.
    # sudo's path can find common commands like echo but not much else.
    def sudo_workaround
      "sudo env PATH=$PATH"
    end


config/unicorn.rb:

    APP_PATH = '/var/www/apps/sparkle'
    worker_processes 4
    user 'rails', 'rails'
    working_directory "#{APP_PATH}/current"
    listen "/tmp/unicorn_sparkle.sock", :backlog => 64
    timeout 30
    pid "#{APP_PATH}/shared/pids/unicorn.pid"
    stderr_path "#{APP_PATH}/shared/log/unicorn.stderr.log"
    stdout_path "#{APP_PATH}/shared/log/unicorn.stdout.log"
    preload_app true
    GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
    
    before_fork do |server, worker|
      defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
    
      old_pid = "#{server.config[:pid]}.oldbin"
      if old_pid != server.pid
        begin
          sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
          Process.kill(sig, File.read(old_pid).to_i)
        rescue Errno::ENOENT, Errno::ESRCH
        end
      end
    end
    
    after_fork do |server, worker|
      defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
    end

This is all with Unicorn 4.2.0 and Rails 3.0.11.

Many thanks in advance,

Andy Stewart
----
http://airbladesoftware.com

_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[relevance 3%]

* Re: Problem restarting Unicorn
  2012-04-05  7:21 Problem restarting Unicorn Andrew Stewart
@ 2012-04-05 11:34 ` Michael Guterl
  0 siblings, 0 replies; 4+ results
From: Michael Guterl @ 2012-04-05 11:34 UTC (permalink / raw)
  To: unicorn list

On Thu, Apr 5, 2012 at 3:21 AM, Andrew Stewart
<boss@airbladesoftware.com> wrote:
> Hello,
>
> I seem to be confused about how to restart Unicorn when deploying updates to a Rails app via Capistrano.
>
> I just had a problem where a bundled gem wasn't being seen by the Unicorn processes, even though app code I introduced at the same time was being served by the Unicorn processes.  I had restarted Unicorn numerous times using `bundle exec cap deploy:restart` (see the code below), which I thought was the right way to do zero-downtime restarts, but my problem was only solved by doing a hard restart of Unicorn with `bundle exec cap deploy:hard_restart`.
>
> With each "normal" restart I tailed the stderr log to check everything was ok; everything appeared fine, with gems refreshed etc.
>
> Please could somebody explain what I'm doing wrong with my normal restarts?
>
> config/deploy.rb:
>
>    set :unicorn_config, "#{current_path}/config/unicorn.rb"
>    set :unicorn_pid,    "#{shared_path}/pids/unicorn.pid"
>
>    namespace :deploy do
>      task :start, :roles => :app, :except => { :no_release => true } do
>        run "cd #{current_path} && #{sudo_workaround} bundle exec unicorn -c #{unicorn_config} -E #{rails_env} -D"
>      end
>      task :stop, :roles => :app, :except => { :no_release => true } do
>        run "#{sudo_workaround} kill -s QUIT `cat #{unicorn_pid}`"
>      end
>      task :hard_stop, :roles => :app, :except => { :no_release => true } do
>        run "#{sudo_workaround} kill `cat #{unicorn_pid}`"
>      end
>      task :restart, :roles => :app, :except => { :no_release => true } do
>        run "#{sudo_workaround} kill -s USR2 `cat #{unicorn_pid}`"
>      end
>      task :hard_restart, :roles => :app, :except => { :no_release => true } do
>        hard_stop
>        start
>      end
>    end
>
>    # Works around Ubuntu changing the PATH when you use sudo.
>    # sudo's path can find common commands like echo but not much else.
>    def sudo_workaround
>      "sudo env PATH=$PATH"
>    end
>
>
> config/unicorn.rb:
>
>    APP_PATH = '/var/www/apps/sparkle'
>    worker_processes 4
>    user 'rails', 'rails'
>    working_directory "#{APP_PATH}/current"
>    listen "/tmp/unicorn_sparkle.sock", :backlog => 64
>    timeout 30
>    pid "#{APP_PATH}/shared/pids/unicorn.pid"
>    stderr_path "#{APP_PATH}/shared/log/unicorn.stderr.log"
>    stdout_path "#{APP_PATH}/shared/log/unicorn.stdout.log"
>    preload_app true
>    GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
>
>    before_fork do |server, worker|
>      defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
>
>      old_pid = "#{server.config[:pid]}.oldbin"
>      if old_pid != server.pid
>        begin
>          sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
>          Process.kill(sig, File.read(old_pid).to_i)
>        rescue Errno::ENOENT, Errno::ESRCH
>        end
>      end
>    end
>
>    after_fork do |server, worker|
>      defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
>    end
>
> This is all with Unicorn 4.2.0 and Rails 3.0.11.
>
> Many thanks in advance,
>

You probably want to check out the Sandbox documentation here:
http://unicorn.bogomips.org/Sandbox.html

The section that I think is most relevant is related to setting the START_CTX:

Unicorn::HttpServer::START_CTX[0] = "/some/path/to/bin/unicorn"

Hope that helps.

Best,
Michael Guterl
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[relevance 0%]

Results 1-4 of 4 | reverse results
2012-01-28  9:25 [ANN] unicorn 4.2.0 - minor fixes and improvements Eric Wong
    [irrelevant] <E8D9E7CCC2621343A0A3BB45E8DEDFA91C6738D58E@CRPMBOXPRD04.polycom.com>
    [irrelevant] ` <20120309222412.GA21753@dcvr.yhbt.net>
    [irrelevant]   ` <E8D9E7CCC2621343A0A3BB45E8DEDFA91C6738D5B7@CRPMBOXPRD04.polycom.com>
    [irrelevant]     ` <20120310000239.GA27195@dcvr.yhbt.net>
    [irrelevant]       ` <E8D9E7CCC2621343A0A3BB45E8DEDFA91C6738D5F8@CRPMBOXPRD04.polycom.com>
    [irrelevant]         ` <20120310013051.GA32091@dcvr.yhbt.net>
    [irrelevant]           ` <20120312212119.GA26451@dcvr.yhbt.net>
    [irrelevant]             ` <E8D9E7CCC2621343A0A3BB45E8DEDFA91C682DD23D@CRPMBOXPRD04.polycom.com>
    [irrelevant]               ` <20120312224419.GA2942@dcvr.yhbt.net>
    [irrelevant]                 ` <20120320195748.GA1187@dcvr.yhbt.net>
2012-03-30 22:16                   ` Unicorn_rails ignores USR2 signal Yeung, Jeffrey
2012-04-05  7:21 Problem restarting Unicorn Andrew Stewart
2012-04-05 11:34 ` Michael Guterl


unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/unicorn-public
	git clone --mirror http://ou63pmih66umazou.onion/unicorn-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git