[#66079] gc_sweep(): unknown data type 48 — Mauricio Fern疣dez <batsman.geo@...>

15 messages 2003/03/01
[#66082] Re: [BUG] gc_sweep(): unknown data type 48 — nobu.nokada@... 2003/03/01

Hi,

[#66085] Re: [BUG] gc_sweep(): unknown data type 48 — Mauricio Fern疣dez <batsman.geo@...> 2003/03/01

On Sat, Mar 01, 2003 at 07:26:58PM +0900, nobu.nokada@softhome.net wrote:

[#66088] Anything like Class::DBI from Perl — pw-googlegroups@... (Peter Wilkinson)

We've been doing some work using Class::DBI in Perl which makes access

17 messages 2003/03/01

[#66217] Prolly a simple question — <ghost-no-spam@...>

Sorry if these questions have come up before, but google searching hasn't

20 messages 2003/03/03

[#66245] TCPSocket delay problem — Seth Kurtzberg <seth@...>

Matz,

23 messages 2003/03/04

[#66269] OSCON — ptkwt@...1.aracnet.com (Phil Tomson)

For those coming to OSCON this year...

18 messages 2003/03/04

[#66315] system command expansion after PTY.spawn — Christian von Mueffling <cvm@...>

Hi!

13 messages 2003/03/05

[#66330] cookies in eruby mod_ruby — Daniel Bretoi <lists@...>

Can someone explain how to set/delete cookies using mod_ruby (eruby)?

13 messages 2003/03/06

[#66332] Russian Ruby resource and Ruby Course — leikind@... (Yuri Leikind)

Hi all,

19 messages 2003/03/06

[#66392] DRB and threads — Brian Candler <B.Candler@...>

I wonder if anyone can give me some hints on the interactions between dRuby

22 messages 2003/03/06
[#66417] Re: DRB and threads — "Robert Klemme" <bob.news@...> 2003/03/07

[#66421] Re: DRB and threads — Brian Candler <B.Candler@...> 2003/03/07

On Fri, Mar 07, 2003 at 07:15:29PM +0900, Robert Klemme wrote:

[#66449] Re: DRB and threads — ahoward <ahoward@...> 2003/03/08

On Fri, 7 Mar 2003, Brian Candler wrote:

[#66454] Re: DRB and threads — Brian Candler <B.Candler@...> 2003/03/08

On Sat, Mar 08, 2003 at 11:38:31AM +0900, ahoward wrote:

[#66440] Solving the 'strange language' documentation problem — "Josef 'Jupp' Schugt" <jupp@...>

Dear Rubyists,

18 messages 2003/03/07

[#66466] I'm to give short talk on ruby at work, anybody have material/outlines they can donate/ — Sam Roberts <sroberts@...>

10 messages 2003/03/08

[#66469] What character sets are available in Ruby ? — peterjohannsen@... (pj)

There is a Ruby FAQ which I read that said that Ruby only supports

17 messages 2003/03/08

[#66522] Thinking of learning Ruby — "anonimous" <n.thomp@...>

I have abour 3 or 4 years experience with Linux, and about 2 years

45 messages 2003/03/10

[#66530] Protocols — "Ray Capozzi" <Ray_Capozzi@...>

Is there a preferred set of ruby libraries for client/server solutions? As

26 messages 2003/03/10
[#66533] Re: Protocols — "MikkelFJ" <mikkelfj-anti-spam@...> 2003/03/10

[#66548] Re: Protocols — <jbritt@...> 2003/03/10

> "Ray Capozzi" <Ray_Capozzi@hotmail.com> wrote in message

[#66633] Threads and DRb — "Hal E. Fulton" <hal9000@...>

I changed the title here because this is not

16 messages 2003/03/10

[#66805] Ruby newbie uninstall question? — "Colin Coates" <colin@...>

Hello Everyone,

12 messages 2003/03/12

[#66850] Ruby / Eiffel ? — <cailloux@...>

Hello evry body

23 messages 2003/03/13

[#66906] Syck 0.08 -- Next-generation of YAML.rb — why the lucky stiff <yaml-core@...>

citizens,

21 messages 2003/03/14
[#66931] Re: [ANN] Syck 0.08 -- Next-generation of YAML.rb — Richard Kilmer <rich@...> 2003/03/14

Works great under OS X and Ruby 1.8!

[#66927] dynamically create a method — Rudolf Polzer <abuse@...>

Is there a possiblilty to dynamically create a method, like this?

14 messages 2003/03/14

[#66974] The onion truck strikes again ... Announcing rake — Jim Weirich <jweirich@...>

Ok, let me state from the beginning that I never intended to write this

25 messages 2003/03/15

[#67013] ANN: vcard 0.1 - a vCard decoding library — Sam Roberts <sroberts@...>

http://raa.ruby-lang.org/list.rhtml?name=vcard

10 messages 2003/03/15

[#67071] How do I get irb to use readline, (with OS X)? — Sam Roberts <sroberts@...>

I'm sure I saw something about this somewhere, but I've been searching,

12 messages 2003/03/16

[#67074] ANN: Madeleine 0.1 — Anders Bengtsson <ndrsbngtssn@...>

28 messages 2003/03/16
[#67109] Re: ANN: Madeleine 0.1 — Brian Candler <B.Candler@...> 2003/03/17

On Mon, Mar 17, 2003 at 07:00:35AM +0900, Anders Bengtsson wrote:

[#67115] Re: ANN: Madeleine 0.1 — Anders Bengtsson <ndrsbngtssn@...> 2003/03/17

--- Brian Candler <B.Candler@pobox.com> skrev:

[#67124] Re: ANN: Madeleine 0.1 — Brian Candler <B.Candler@...> 2003/03/17

On Mon, Mar 17, 2003 at 11:37:56PM +0900, Anders Bengtsson wrote:

[#67128] Re: ANN: Madeleine 0.1 — Anders Bengtsson <ndrsbngtssn@...> 2003/03/17

--- Brian Candler <B.Candler@pobox.com> wrote:

[#67222] OT: XML too hard (YAML opportunity?) — ptkwt@...1.aracnet.com (Phil Tomson)

On /. today there is a discussion about a weblog entry by an XML

27 messages 2003/03/18
[#67239] Re: XML too hard (YAML opportunity?) — <jbritt@...> 2003/03/19

> On /. today there is a discussion about a weblog entry by an XML

[#67302] Frequency of announcements — "Josef 'Jupp' Schugt" <jupp@...>

Hi!

14 messages 2003/03/19

[#67304] Strong advantages over Python — Greg McIntyre <greg@...>

Hi lovely Ruby people,

111 messages 2003/03/20
[#67408] Re: Strong advantages over Python — Greg McIntyre <greg@...> 2003/03/21

Good list. Amalgamated with http://www.ruby-lang.org/en/whats.html, it

[#67416] Re: Strong advantages over Python — Paul Prescod <paul@...> 2003/03/21

Greg McIntyre wrote:

[#67663] Ruby lecture slides (was Strong advantages over Python) — Greg McIntyre <greg@...> 2003/03/23

Thanks to all of you who answered and cleared up some of my perceptions

[#67675] Re: Ruby lecture slides (was Strong advantages over Python) — Paul Prescod <paul@...> 2003/03/23

Greg McIntyre wrote:

[#67685] Re: Ruby lecture slides (was Strong advantages over Python) — Mark Wilson <mwilson13@...> 2003/03/24

[#67697] Re: Ruby lecture slides (was Strong advantages over Python) — Greg McIntyre <greg@...> 2003/03/24

Mark Wilson <mwilson13@cox.net> wrote:

[#67346] class level Exception handling — Xiangrong Fang <xrfang@...>

Hi

12 messages 2003/03/20

[#67366] Newbie question: 9/5=1 ? — Thomas Jollans <nospam@...>

while learning ruby i wanted to program a simple fahrenheit to celsius

16 messages 2003/03/20

[#67387] Ruby tutorial download — Daniel Carrera <dcarrera@...>

Someone asked that I make the ruby tutorial available for download,

13 messages 2003/03/20

[#67415] Proposal: new operator: '<-' (for assignments) — ptkwt@...1.aracnet.com (Phil Tomson)

15 messages 2003/03/21

[#67446] Ruby & LaTeX — Walter Cazzola <cazzola@...>

Dear Ruby Experts,

19 messages 2003/03/21

[#67514] Rake problem? — manfred.lotz@... (Manfred)

Hi,

15 messages 2003/03/21

[#67546] Expression results — debitsch@... (Rasmus)

Hello,

22 messages 2003/03/21
[#67549] Re: Expression results — "Hal E. Fulton" <hal9000@...> 2003/03/21

----- Original Message -----

[#67634] exiting a loop — Daniel Carrera <dcarrera@...>

Hello,

31 messages 2003/03/23

[#67711] Iterate over two lists in parallel — Gavin Sinclair <gsinclair@...>

On Monday, March 24, 2003, 1:54:53 PM, Julian wrote:

33 messages 2003/03/24

[#67915] Conditionally make a method private? — Jeremy <thinker5555@...>

Hello again!

13 messages 2003/03/26

[#67961] What are the differences between Ruby's blocks and Python's lambdas? — sdieselil@... (sdieselil)

See subject.

22 messages 2003/03/26
[#67966] Re: What are the differences between Ruby's blocks and Python's lambdas? — "Chris Pine" <nemo@...> 2003/03/26

As was mentioned, Ruby has lambdas, but they are commonly called "procs".

[#67967] Re: What are the differences between Ruby's blocks and Python's lambdas? — Mauricio Fern疣dez <batsman.geo@...> 2003/03/26

On Thu, Mar 27, 2003 at 12:50:04AM +0900, Chris Pine wrote:

[#67975] Re: What are the differences between Ruby's blocks and Python's lambdas? — Paul Brannan <pbrannan@...> 2003/03/26

On Thu, Mar 27, 2003 at 01:01:25AM +0900, Mauricio Fern疣dez wrote:

[#67983] Re: What are the differences between Ruby's blocks and Python's lambdas? — Mauricio Fern疣dez <batsman.geo@...> 2003/03/26

On Thu, Mar 27, 2003 at 02:20:48AM +0900, Paul Brannan wrote:

[#67986] Re: What are the differences between Ruby's blocks and Python's lambdas? — Paul Brannan <pbrannan@...> 2003/03/26

On Thu, Mar 27, 2003 at 04:40:40AM +0900, Mauricio Fern疣dez wrote:

[#68082] Array question — walter@...

Any one know why Array.join can't take a code block and join that

28 messages 2003/03/27

[#68198] Announce: RHDL-0.4.2 (Ruby HDL) an agile HDL — ptkwt@...1.aracnet.com (Phil Tomson)

RHDL 0.4.2 is now available at:

12 messages 2003/03/29

[#68199] Ruby 1.6.8 vs Ruby 1.8.0 preview 2 - benchmarks — djberg96@... (Daniel Berger)

Hi all,

11 messages 2003/03/29

[#68201] Weighted random selection -- how would you do this? — "Hal E. Fulton" <hal9000@...>

Here's a little question for you.

24 messages 2003/03/29

[#68254] Saving code written during an irb session — Bil Kleb <W.L.Kleb@...>

OK, so I admit: I'm stupid. How do I save the code I've generated

19 messages 2003/03/30

[#68271] Hard coded newline characters — David King Landrith <dave@...>

There are a surprising number of ruby source files that have newline

24 messages 2003/03/30
[#68286] Re: Hard coded newline characters — nobu.nokada@... 2003/03/31

Hi,

[#68328] Re: Hard coded newline characters — David King Landrith <dave@...> 2003/03/31

On Sunday, March 30, 2003, at 08:06 PM, nobu.nokada@softhome.net wrote:

[#68318] syntax highlighting problem in vim — "Josef 'Jupp' Schugt" <jupp@...>

Hi!

16 messages 2003/03/31
[#68325] Re: syntax highlighting problem in vim — KONTRA Gergely <kgergely@...> 2003/03/31

Negative. It is correct for me. How is it displayed at you?

Re: DRB and threads

From: Brian Candler <B.Candler@...>
Date: 2003-03-08 13:16:05 UTC
List: ruby-talk #66454
On Sat, Mar 08, 2003 at 11:38:31AM +0900, ahoward wrote:
> > I quite like the Apache/FastCGI approach because the code for allocating
> > instances of the backend is already written and hopefully reasonably
> > debugged; it can have a fixed or variable number of instances.
> 
> debugged, but not user friendly.  i wrote a little wrapper that dealt with
> much of the signal handling, and used someone else pattern (i forget whose) to
> boot strap a normal cgi objec of off a fcgi object.  it's at
> 
> http://groups.google.com/groups?q=ahoward+mod_fcgi+group:comp.lang.ruby&hl=en&lr=&ie=UTF-8&selm=Pine.LNX.4.33.0302121430040.10747-100000%40eli.fsl.noaa.gov&rnum=1

Yes, I found this sufficiently interesting that I kept a copy when you first
posted it, so thanks for reminding me! It's [ruby-talk:64468] for a shorter
link.

Did you find that installing a SIGPIPE handler was actually necessary? 
According to the mod_fastcgi documentation, mod_fastcgi itself sets this for
applications which it spawns; also libfcgi installs an empty signal handler
for SIGPIPE as well (OS_SigpipeHandler in libfcgi/os_unix.c)

I removed install_traps and sent a kill -PIPE to the spawned process and it
didn't seem to blink, so I think it's not actually necessary (but perhaps it
is with the pure Ruby version of fcgi)

A few other points:

* you call '@@server.close' but this ties you to the pure-Ruby
implementation; I am using the C version and it doesn't set such an instance
variable. This means you can get warnings logged such as

mod_fcgi.rb:in `install_traps': uninitialized class variable @@server in MOD_FCGI (NameError)

* the trapping of TERM and HUP doesn't work properly for me. What happens is
that if I send such a signal to the process, nothing happens (ps shows the
same pid) until the next HTTP request comes along, at which point it fails
and Apache returns '500 Internal Server Error'. The process is then
restarted and it's fine thereafter.

I put some file debugging in:

  $stderr = File.open("/tmp/errs","a")
  $stderr.sync = true
  ...

  trap('SIGHUP') do
    $stderr.puts "#{Time.now} signals #{@@signals.inspect} handling_request #{@@handling_request.inspect} exit_requested #{@@exit_requested.inspect}"
  ...

What seems to happen is that the trap handler is not even started until the
subsequent request comes in, as shown by the timestamp. The process *then*
commits suicide (since @@handling_request is still false at that point) and
the 500 error occurs. Changing 'exit' to 'exit!' doesn't make any difference
either.

It's as if the signal is held up in accept() until the next incoming
connection arrives. I can't work out why this is the case, but for now just
removing 'install_traps' actually gives me much better results, since the
process just dies and is respawned straight away.

FYI I am running ruby 1.6.8 (2002-12-24) [i386-freebsd4.7] with
ruby-fcgi-0.8.1 + fcgi-2.4.0, apache-1.3.27, mod_fastcgi-2.2.12

* I also had to make a few changes to make it load cleanly under ruby -w
(attached)

Otherwise this all looks very cool, and I actually don't think that it's
Apache-specific. SIGPIPE isn't an Apache extension to fastcgi spec, it just
closes the socket if it isn't interested in waiting for the response, and
the OS generates SIGPIPE. Other fastcgi servers are likely to do the same.

As a result, I think that what you've written really belongs in the core
FCGI library anyway, i.e.

  - bootstrapping of a CGI object (maybe FCGI.each_cgi ?)

and perhaps also optional graceful shutdown on USR1, if it can be made to
work (although that _is_ an Apache feature)

Or else at least it can go on the RubyGardenWiki ?

Regards,

Brian.

P.S. Thinking about USR1, I just checked and libfcgi does install a USR1
handler (which sets an interal flag for a graceful abort). However it
doesn't work very well if the process is between requests, because it just
sits in accept() and catches the signal, so doesn't abort until the next
incoming connection occurs, giving a 500 error to the client.

Attachments (1)

mod_fcgi.rb.patch (2.31 KB, text/x-diff)
--- mod_fcgi.rb.orig	Sat Mar  8 10:06:51 2003
+++ mod_fcgi.rb	Sat Mar  8 12:46:08 2003
@@ -59,7 +59,7 @@
       if $SAFE > 0 and tmpdir.tainted?
 	tmpdir = '/tmp'
       end
-      basename ||= File.basename $0
+      basename ||= File.basename($0)
       n = 0
       while true
 	begin
@@ -96,7 +96,7 @@
     def initialize(request, *args)
       self.class.remove_params
       @request = request
-      super (*args)
+      super(*args)
       @args = *args
     end
     def args
@@ -134,13 +134,13 @@
       # user signal to reload application
       # does a clean shutdown after which
       # the fcgi_pm will reload of source file
-      trap ('SIGHUP') do
+      trap('SIGHUP') do
 	unless @@signals.size > 0
 	  @@signals << 'SIGHUP'
 	  if @@handling_request
 	    @@exit_requested = true
 	  else
-	    @@server.close
+	    @@server.close if defined? @@server
 	    exit
 	  end
 	end
@@ -149,24 +149,24 @@
       # sent from apache to do clean shutdown
       # note that a sigterm could be sent from fcgi_pm
       # AFTER this!  we handle only one of them!
-      trap ('SIGUSR1') do
+      trap('SIGUSR1') do
 	unless @@signals.size > 0
 	  @@signals << 'SIGUSR1'
 	  if @@handling_request
 	    @@exit_requested = true
 	  else
-	    @@server.close
+	    @@server.close if defined? @@server
 	    exit
 	  end
 	end
       end
 
       # see above note.
-      # when no other signals pedning, simply exit quickly
-      trap ('SIGTERM') do
+      # when no other signals pending, simply exit quickly
+      trap('SIGTERM') do
 	unless @@signals.size > 0
 	  @@signals << 'SIGTERM'
-	  @@server.close
+	  @@server.close if defined? @@server
 	  exit
 	end
       end
@@ -174,7 +174,7 @@
       # sent from mod_fcgi when client aborts request
       # we simply ignore this for now, although some smarts could be
       # added to abort the present request and resume accepting...
-      trap ('SIGPIPE') do
+      trap('SIGPIPE') do
 	# nothing
       end
 
@@ -182,15 +182,15 @@
     end
 
     def each (*args)
-      install_traps
+      #install_traps can be called by the user first
       while request = accept
 	handle_request {
 	  if block_given?
-	    yield (CGI.new (request, *args))
+	    yield(CGI.new(request, *args))
 	    request.finish
 	  end
 	}
-	exit if @@exit_requested
+	break if @@exit_requested
       end
     end
 

In This Thread