unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Multiple master processes
@ 2011-01-31  9:47 Tilmann Singer
  2011-01-31 18:08 ` Eric Wong
  2011-01-31 19:24 ` Jamie Wilkinson
  0 siblings, 2 replies; 5+ messages in thread
From: Tilmann Singer @ 2011-01-31  9:47 UTC (permalink / raw)
  To: mongrel-unicorn

Hi,

I'm seeing the following output of ps after starting unicorn, which as
I understand it means that there are multiple master processes
running, each with its own pid. Is that normal behaviour or is there
something wrong with my setup?


$ ps xf|grep 4002
 8022 ?        S      0:00 unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
 8024 ?        S      0:00  \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
26743 ?        S      0:00  |   \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
26734 ?        S      0:22  \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
26736 ?        S      0:00  |   \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
26739 ?        S      0:00  |       \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
26737 ?        S      0:22  \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
26740 ?        S      0:00  |   \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
26741 ?        S      0:00  |       \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
26742 ?        S      0:21  \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
26744 ?        S      0:00      \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
26745 ?        S      0:00          \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
$ cat tmp/pids/unicorn.pid
8022


This is on Linux 2.4.27, ruby 1.9.2, unicorn 3.3.1, rails 3.0.3 in an
rvm gemset.

# config/unicorn.rb
worker_processes 3
pid "tmp/pids/unicorn.pid"
stderr_path "log/unicorn.stderr.log"
stdout_path "log/unicorn.stdout.log"

I start unicorn like this:
unicorn -c config/unicorn.rb -E production -p 4002 -D

Using "bundle exec unicorn" or unicorn_rails instead doesn't seem to
make a difference.

Starting the same project on my desktop with I believe is mostly the
same setup except that it is Linux 2.6.34, the process list looks like
this, which looks normal to me:

$ ps xf|grep 4002
 2692 ?        Sl     0:00 unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
 2695 ?        Rl     0:05  \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
 2698 ?        Rl     0:05  \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
 2700 ?        Rl     0:05  \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      




Til
_______________________________________________
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] 5+ messages in thread

* Re: Multiple master processes
  2011-01-31  9:47 Multiple master processes Tilmann Singer
@ 2011-01-31 18:08 ` Eric Wong
  2011-02-01 20:48   ` Tilmann Singer
  2011-01-31 19:24 ` Jamie Wilkinson
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Wong @ 2011-01-31 18:08 UTC (permalink / raw)
  To: unicorn list

Tilmann Singer <tils@tils.net> wrote:
> Hi,
> 
> I'm seeing the following output of ps after starting unicorn, which as
> I understand it means that there are multiple master processes
> running, each with its own pid. Is that normal behaviour or is there
> something wrong with my setup?

It's normal behavior for Linux 2.4.x + Ruby 1.9, don't worry about it.

> $ ps xf|grep 4002
>  8022 ?        S      0:00 unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
>  8024 ?        S      0:00  \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> 26743 ?        S      0:00  |   \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> 26734 ?        S      0:22  \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26736 ?        S      0:00  |   \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26739 ?        S      0:00  |       \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26737 ?        S      0:22  \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26740 ?        S      0:00  |   \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26741 ?        S      0:00  |       \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26742 ?        S      0:21  \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26744 ?        S      0:00      \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26745 ?        S      0:00          \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
> $ cat tmp/pids/unicorn.pid
> 8022
> 
> This is on Linux 2.4.27, ruby 1.9.2

With LinuxThreads in 2.4, the native threads used by Ruby 1.9 each had a
unique PID and /proc entry whereas with NPTL in 2.6 hides the top-level
entries of tasks that weren't processes (still visible in
/proc/$pid/task/*)

"tasks" are just the in-kernel representation of either processes and
native threads in all Linux versions.  They're created via the same
system call, clone(2), so pthread_create() and fork() are just wrappers
around clone() with different arguments.  It's just 2.4 had fewer
options for clone() that made it weirder and less POSIX-conformant.

The pthreads(7) manpage has more details on the differences between NPTL
and LinuxThreads.

Wow, I didn't realize people ran the latest Rubies on 2.4.x!

-- 
Eric Wong
_______________________________________________
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] 5+ messages in thread

* Re: Multiple master processes
  2011-01-31  9:47 Multiple master processes Tilmann Singer
  2011-01-31 18:08 ` Eric Wong
@ 2011-01-31 19:24 ` Jamie Wilkinson
  1 sibling, 0 replies; 5+ messages in thread
From: Jamie Wilkinson @ 2011-01-31 19:24 UTC (permalink / raw)
  To: unicorn list

On Jan 31, 2011, at 1:47 AM, Tilmann Singer wrote:

> Hi,
> 
> I'm seeing the following output of ps after starting unicorn, which as
> I understand it means that there are multiple master processes
> running, each with its own pid. Is that normal behaviour or is there
> something wrong with my setup?
> 
<snip>

> # config/unicorn.rb
> worker_processes 3
> pid "tmp/pids/unicorn.pid"
> stderr_path "log/unicorn.stderr.log"
> stdout_path "log/unicorn.stdout.log"

Unicorn doesn't kill the old master on it's own, you need an after_fork() like so (from the default/suggested unicorn conf) 

http://unicorn.bogomips.org/examples/unicorn.conf.rb 
_______________________________________________
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] 5+ messages in thread

* Re: Multiple master processes
  2011-01-31 18:08 ` Eric Wong
@ 2011-02-01 20:48   ` Tilmann Singer
  2011-02-01 21:22     ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Tilmann Singer @ 2011-02-01 20:48 UTC (permalink / raw)
  To: unicorn list

At Mon, 31 Jan 2011 18:08:15 +0000,
Eric Wong <normalperson@yhbt.net> wrote:
> 
> Tilmann Singer <tils@tils.net> wrote:
> > I'm seeing the following output of ps after starting unicorn, which as
> > I understand it means that there are multiple master processes
> > running, each with its own pid. Is that normal behaviour or is there
> > something wrong with my setup?
> 
> It's normal behavior for Linux 2.4.x + Ruby 1.9, don't worry about it.

OK thanks, good to know.


> > $ ps xf|grep 4002
> >  8022 ?        S      0:00 unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> >  8024 ?        S      0:00  \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> > 26743 ?        S      0:00  |   \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
[...]
> > $ cat tmp/pids/unicorn.pid
> > 8022

Could it be that the content of the pidfile is wrong in this case? I
found that I always have to signal the pid of the last of the master
process list entries (26743 in this example) to see them have an
effect. Not a big deal, just wondering.


> Wow, I didn't realize people ran the latest Rubies on 2.4.x!

Time to upgrade for me I assume ...


greetings, Til
_______________________________________________
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] 5+ messages in thread

* Re: Multiple master processes
  2011-02-01 20:48   ` Tilmann Singer
@ 2011-02-01 21:22     ` Eric Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2011-02-01 21:22 UTC (permalink / raw)
  To: unicorn list

Tilmann Singer <tils@tils.net> wrote:
> > > $ ps xf|grep 4002
> > >  8022 ?        S      0:00 unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> > >  8024 ?        S      0:00  \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> > > 26743 ?        S      0:00  |   \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> [...]
> > > $ cat tmp/pids/unicorn.pid
> > > 8022
> 
> Could it be that the content of the pidfile is wrong in this case? I
> found that I always have to signal the pid of the last of the master
> process list entries (26743 in this example) to see them have an
> effect. Not a big deal, just wondering.

Probably, I don't think there's a reliable way to get the pid
dedicated to signal handling with LinuxThreads...

> > Wow, I didn't realize people ran the latest Rubies on 2.4.x!
> 
> Time to upgrade for me I assume ...

Definitely, especially since you're using Ruby 1.9.2 :)

-- 
Eric Wong
_______________________________________________
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] 5+ messages in thread

end of thread, other threads:[~2011-02-01 21:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-31  9:47 Multiple master processes Tilmann Singer
2011-01-31 18:08 ` Eric Wong
2011-02-01 20:48   ` Tilmann Singer
2011-02-01 21:22     ` Eric Wong
2011-01-31 19:24 ` Jamie Wilkinson

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).