setup (God)

    # File lib/god.rb, line 531
      def self.setup
        if self.pid_file_directory
          # pid file dir was specified, ensure it is created and writable
          unless File.exist?(self.pid_file_directory)
            begin
              FileUtils.mkdir_p(self.pid_file_directory)
            rescue Errno::EACCES => e
              abort "Failed to create pid file directory: #{e.message}"
            end
          end

          unless File.writable?(self.pid_file_directory)
            abort "The pid file directory (#{self.pid_file_directory}) is not writable by #{Etc.getlogin}"
          end
        else
          # no pid file dir specified, try defaults
          PID_FILE_DIRECTORY_DEFAULTS.each do |idir|
            dir = File.expand_path(idir)
            begin
              FileUtils.mkdir_p(dir)
              if File.writable?(dir)
                self.pid_file_directory = dir
                break
              end
            rescue Errno::EACCES => e
            end
          end

          unless self.pid_file_directory
            dirs = PID_FILE_DIRECTORY_DEFAULTS.map { |x| File.expand_path(x) }
            abort "No pid file directory exists, could be created, or is writable at any of #{dirs.join(', ')}"
          end
        end

        applog(nil, :info, "Using pid file directory: #{self.pid_file_directory}")
      end