[codeforpeople-rocks] Question about Bj and ENV variables

Erik Morton eimorton at gmail.com
Tue Sep 2 19:31:12 EDT 2008

First off, I really like Bj. I've used Backgroundrb in a critical  
production environment for years, but I need something a little more  
lightweight for a current project. Plus Bj comes with job auditing  
built in! Awesome.

I'm having some trouble with the infamous RubyInline library required  
by ImageScience and I was hoping you could point me to some best  
practices for deploying Bj in "diverse" production environments. Allow  
me to explain:

Cluster of Mongrels
Java FTP server

The scenario is simple: a user uploads a file to FTP and a custom Java  
event handler shells out to a ruby script that simply POSTS the file  
to the rails app running in the customer of mongrels. A simple way for  
Ruby and Java to live together. Note that the FTP server was running  
as root and therefore had HOME=/root. The mongrels are running as  
my_user with HOME=/home/my_user

Here's my problem: For actions initiated from browser to mongrel I  
have no problems. However, for actions initiated by posting from the  
ruby script that was kicked off by the Java handler I receive the  
infamous Permission denied - /root/.ruby_inline - (Errno::EACCES)  
error. Now I *think* that this is because the Java process was running  
as root and the subprocess it spawned to kick off the Ruby script  
through Runtime.exec inherits the ENV of the parent Java process. What  
confuses me is why, if Bj is running in a separate process that  
initially kicked off by the Mongrel and *not* the subprocess of Java  
(I think that's how it works anyway :-/), is the Bj job using root's  

So the simple answer could be that I'm insane. But there's a gap in my  
understanding as to how exactly Bj jobs are getting their ENV  
variables. For what it is worth my "solution" was to force RubyInline  
to always use /home/my_user through a script in /etc/profile.d that  
set INLINEHOME to /home/my_user.

I'm on Fedora with the kernel and Ruby 1.8.6.

Many many thanks in advance!


More information about the codeforpeople-rocks mailing list