unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Re: Suggestion for reload action (USR2)
@ 2010-01-20  9:20 Iñaki Baz Castillo
  2010-01-20 20:03 ` Eric Wong
  0 siblings, 1 reply; 6+ messages in thread
From: Iñaki Baz Castillo @ 2010-01-20  9:20 UTC (permalink / raw)
  To: mongrel-unicorn

El Miércoles, 20 de Enero de 2010, Iñaki Baz Castillo escribió:

> This would involve just three changes:
> 
> - Add an option "--reload" in OptionParser in bin/unicorn.
> - Store such option somewhere so it can be readed later by the Rack
> application or other library.
> - Add "--reload" to the list of original arguments when receiving USR2.

I attach a patch (for master branch) that would do the job (except the 
fact that I don't know how to store the "reload" option):


-----------------------------------------
diff --git a/bin/unicorn b/bin/unicorn
index 5af021d..43f5434 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -88,6 +88,10 @@ opts = OptionParser.new("", 24, '  ') do |opts|
     options[:config_file] = f
   end

+  opts.on("--reload", "HIDDEN") do |f|
+    # TODO: Store it somewhere
+  end
+
   # I'm avoiding Unicorn-specific config options on the command-line.
   # IMNSHO, config options on the command-line are redundant given
   # config files and make things unnecessarily complicated with multiple
@@ -96,7 +100,7 @@ opts = OptionParser.new("", 24, '  ') do |opts|
   opts.separator "Common options:"

   opts.on_tail("-h", "--help", "Show this message") do
-    puts opts.to_s.gsub(/^.*DEPRECATED.*$/s, '')
+    puts opts.to_s.gsub(/^.*DEPRECATED.*$/s, '').gsub(/^.*HIDDEN.*$/s, '')
     exit
   end

diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index e3e4315..49ad79b 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -519,7 +519,7 @@ module Unicorn
         end
         logger.info "executing #{cmd.inspect} (in #{Dir.pwd})"
         before_exec.call(self)
-        exec(*cmd)
+        exec(*cmd << "--reload")
       end
       proc_name 'master (old)'
     end
-----------------------------------------


The patch is available here:
  http://oversip.net/public/unicorn_reload.patch

(unfortunatelly I cannot attach files in this mailist as the mail is 
rejected).


Regards.


-- 
Iñaki Baz Castillo <ibc@aliax.net>
_______________________________________________
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 related	[flat|nested] 6+ messages in thread
* Suggestion for reload action (USR2)
@ 2010-01-20  8:54 Iñaki Baz Castillo
  0 siblings, 0 replies; 6+ messages in thread
From: Iñaki Baz Castillo @ 2010-01-20  8:54 UTC (permalink / raw)
  To: mongrel-unicorn

Hi, when Unicorn receives a USR2 it invokes the original script and arguments 
and creates a new master as a child.

However when running this new master there could be something to treat 
different as when we run Unicorn for first time.

For example:
- In the initial unicorn master I want it to create a Posix_mq, and in case it 
already exists then I want it to delete and create again.
- But in the new master (when USR2) I just want it to reuse the existing 
Posiq_mq.

Note this is just an example, perhaps not the best however.

So I suggest the following:

- When unicorn master receives a USR2 it executes the original executable 
withthe original arguments plus "--reload". This just would mean that the new 
instance is a reloaded process. The executable could store such option 
somewhere so the application could know it and react.

This would involve just three changes:

- Add an option "--reload" in OptionParser in bin/unicorn.
- Store such option somewhere so it can be readed later by the Rack 
application or other library.
- Add "--reload" to the list of original arguments when receiving USR2.

Opinnions?


-- 
Iñaki Baz Castillo <ibc@aliax.net>
_______________________________________________
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	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-21 11:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-20  9:20 Suggestion for reload action (USR2) Iñaki Baz Castillo
2010-01-20 20:03 ` Eric Wong
2010-01-20 20:22   ` Iñaki Baz Castillo
2010-01-20 20:58     ` Eric Wong
2010-01-21 11:20       ` Iñaki Baz Castillo
  -- strict thread matches above, loose matches on Subject: below --
2010-01-20  8:54 Iñaki Baz Castillo

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).