From: Davertron Date: 2009-03-15T00:33:06+09:00 Subject: Daemons and Paths So I've written a daemon using the 'daemons' gem. I have essentially 3 pieces: daemon_controller => Controls startup/shutdown of daemon (in the style of the first example of the daemons documentation) daemonized_script => This script is the main program; it runs continuously in the background looking for work to do, and when it finds work, it forks itself and uses 'exec' to run a worker worker => processes the job given to it by the daemonized_script and exits The problem I'm having is that my worker program expects to be able to 'require' a few other classes I've written. It expects them to be in the same directory as it (or in a lib directory one dir up, whatever). The obvious issue here is that when the daemon_controller executes the daemonized_script as a daemon, it changes the directory to '/' and executes from there. I temporarily fixed this issue by putting in absolute paths in my source code to test and verify that everything else works as expected, which it does, so my question is this; how do I get a dynamic path set so that the worker process doesn't error when it can't find the files it needs? I can't use absolute paths because my program won't always be installed to the same directory, and anyway that's not a very flexible solution. I should also mention that all of these files live in the same directory structure, so relative paths should work fine. In other words, I'm not putting daemon_controller somewhere else in the filesystem and then trying to call my other files from there; they'll all be either in the same directory, or in close proximity to each other so that I only have change a directory up or down to get to the other files. Any response will be much appreciated.