def acquire_lock
      return true if @lock_handle
      begin
        @lock_handle = File.open(lock_file_path, File::RDWR | File::CREAT)
        raise StandardError.new('Already locked') unless @lock_handle.flock(File::LOCK_EX | File::LOCK_NB)
        @lock_handle.rewind
        @lock_handle.truncate 0
        @stat_handle = File.open(status_file_path, File::RDWR | File::CREAT)
        raise StandardError.new('Failed to open status') unless @stat_handle
        @stat_handle.rewind
        @stat_handle.truncate 0
      rescue
        if @stat_handle
          @stat_handle.close rescue nil
        end
        if @lock_handle
          @lock_handle.flock(File::LOCK_UN) rescue nil
          @lock_handle.close rescue nil
        end
        @stat_handle = nil
        @lock_handle = nil
      end
      !!@lock_handle
    end
def acquire_lock
      return true if @lock_handle
      begin
        @lock_handle = File.open(lock_file_path, File::RDWR | File::CREAT)
        raise StandardError.new('Already locked') unless @lock_handle.flock(File::LOCK_EX | File::LOCK_NB)
        @lock_handle.rewind
        @lock_handle.truncate 0
        @stat_handle = File.open(status_file_path, File::RDWR | File::CREAT)
        raise StandardError.new('Failed to open status') unless @stat_handle
        @stat_handle.rewind
        @stat_handle.truncate 0
      rescue
        if @stat_handle
          @stat_handle.close rescue nil
        end
        if @lock_handle
          @lock_handle.flock(File::LOCK_UN) rescue nil
          @lock_handle.close rescue nil
        end
        @stat_handle = nil
        @lock_handle = nil
      end
      !!@lock_handle
    end
Acquires the lock on the status/lock file.

 Returns true on success or if this instance already holds the lock.
 Returns false if another process holds the lock.