From: Davertron Date: 2009-03-16T21:47:43+09:00 Subject: Re: Daemons and Paths On Mar 14, 6:33 pm, Michael Linfield wrote: > Michael Linfield wrote: > > I don't know if this is exactly what your looking for, but how about a > > call to locate? > > > begin > > #worker code here > > > rescue > > path = %x[locate ].chomp! > > #the filename would be whatever the daemon is > > #looking for - you take the error code from > > #the daemon and pull the filename out of it > > > #Here we are going to take the path output > > #then remove the last array element it's > > #split by, aka the filename, so that u will > > #have the directory > > > directory = path.split("/") > > directory.pop > > directory.join("/") > > Dir.chdir(directory) > > > retry #retries the begin block > > > end > > My apologies, correct the line that says directory.join("/") to the > following: > > directory = directory.join("/") > > Regards, > > - Mac > -- > Posted viahttp://www.ruby-forum.com/. Thanks Michael. You're right, it's not exactly what I'm looking for, but it would probably work. I was looking more towards modifying my RUBYPATH environment variable to get this work; something that doesn't require putting in a bunch of special-case code inside of the source itself, especially above all of my "require" statements. I was thinking of writing a "locate_and_require" statement with your suggestions above if there really is no "right" way to do this. I've never written daemons before, so I don't really know how people generally handle this, and perhaps my expectations are out-of-whack. Anyway, I did find code that shows modifying of the $: variable inside a script to add/change your ruby path; however, it doesn't look like the changes survive daemonization. I'll keep looking around and post how I solved this once I get there.