Ruby IO on brand new xserve with Leopard Server

Hi

I'm using princexml pdf generation in one of our apps and bump into this very weird problem. On our ubuntu box and local machines (MacBook Pro) pdfs are generated flawlessly. On the production xserve (running the rails app in production mode on a mongrel cluster), a 2.8 GHz Quad-Core Intel Xeon, strange things start happening. The following sections give back nil values in production, but valid values in development (script/console, …) even on the xserve itself:

     @exe_path = `which prince`.chomp

     # Actually call the prince command, and pass the entire data stream back.
     pdf = IO.popen(path, "w+")
     pdf.puts(string)
     pdf.close_write
     pdf.gets(nil)

When i call the commands manually from the console, they work, giving back a valid PDF file. In production mode, both are nil, bombing the application. It's almost as if the ruby code is too fast to wait for the system call result. I've tried just about everything possible, even going as far as putting delays between each command, with no result whatsoever.

Has anyone experiences similar issues either on leopard server (default ruby bundled with the system) or an xserve?

Thanks in advance

Peter

I don't know if this was a transcription problem or if this is the actual code you run, but I can't see how it would work on any platform. You set @exe_path but then don't use it in IO.popen().

Another thing to look at is permissions. Does the process owner on the xserve have permissions to WRITE to the specified path? It might be failing silently on the xserve.

cr

I’m using princexml pdf generation in one of our apps and bump into

this very weird problem. On our ubuntu box and local machines

(MacBook Pro) pdfs are generated flawlessly. On the production xserve

(running the rails app in production mode on a mongrel cluster), a

2.8 GHz Quad-Core Intel Xeon, strange things start happening. The

following sections give back nil values in production, but valid

values in development (script/console, …) even on the xserve itself:

@exe_path = `which prince`.chomp
# Actually call the prince command, and pass the entire data

stream back.

pdf = IO.popen(path, "w+")
pdf.puts(string)
pdf.close_write
pdf.gets(nil)

I don’t know if this was a transcription problem or if this is the

actual code you run, but I can’t see how it would work on any

platform. You set @exe_path but then don’t use it in IO.popen().

Those are two sections of code. Here’s the complete code:

http://sublog.subimage.com/articles/2007/05/29/html-css-to-pdf-using-ruby-on-rails

The prince class can be seen here: http://pastie.caboo.se/146952

Another thing to look at is permissions. Does the process owner on the

xserve have permissions to WRITE to the specified path? It might be

failing silently on the xserve.

It doesn’t write anything, it just writes a command to the command line as far as I see. (Well, it does, to STDIN). Unless I’m missing something in the prince class.

Best regards

Peter De Berdt