backgroundrb help needed!

I have what I thought would be a simple thing - we use backgroundrb to
watch a directory and process new files. We want to make sure that the
worker is running. I thought I could have a schedule that started the
worker every 5 minutes to make sure, but, it loads a new one each time
(not surprising).
Is there a way to make sure that there is one (and only one) of these
workers running at all times?

Hi Phil,

BackgrounDRb or no, creating a file containing the process's PID, and
verifying that each time the process is started is the typical unixy
way to do this. How I do it:

  def self.is_running?
    if File.exists? pidfile
        Process.kill 0, pid
        return true
      rescue Errno::EPERM
        puts "You don't own this process."
        return true
      rescue Errno::ESRCH #pid doesn't exist anymore

  def self.delete_pidfile
    File.delete pidfile

  def rescue nil

  def self.pidfile

And of course just create the the appropriate file writing
to it.