private function initFailureFile()
    {
        $this->baseDir = getenv('GOOGLE_CLOUD_BATCH_DAEMON_FAILURE_DIR');
        if ($this->baseDir === false) {
            $this->baseDir = sprintf(
                '%s/batch-daemon-failure',
                sys_get_temp_dir()
            );
        }
        if (! is_dir($this->baseDir)) {
            if (@mkdir($this->baseDir, 0700, true) === false) {
                throw new \RuntimeException(
                    sprintf(
                        'Couuld not create a directory: %s',
                        $this->baseDir
                    )
                );
            }
        }
        // Use getmypid for simplicity.
        $this->failureFile = sprintf(
            '%s/failed-items-%d',
            $this->baseDir,
            getmypid()
        );
    }