Saves the run attempt.

@param Run $run
166920
private function saveRun(Run $run)
    {
        $this->jobModel->last_ran = time();
        $this->jobModel->last_run_succeeded = $run->succeeded();
        $this->jobModel->last_run_output = $run->getOutput();
        $this->jobModel->save();
    }
298427
private function runRunnable($runnable)
    {
        if (!$runnable) return;

        $runnable->run();
        if ($runnable->getException()) {
            self::$console->setExitStatus(1);
            if (self::$console->options['stop']) {
                $this->reporter->afterRun();
                exit(1);
            }
        }
    }
1314640
public function save()
    {
        if ($path = $this->getProjectPath()) {
            $path .= '/' . $this->getOutputFile();
            file_put_contents($path, serialize($this->getContainer()));
        } else {
            throw new \RuntimeException('No project path provided.');
        }
        return $this;
    }
748415
public final void removeRun(RunT run) {
        if (!builds.remove(run)) {
            LOGGER.log(Level.WARNING, "{0} did not contain {1} to begin with", new Object[] {asJob(), run});
        }
    }
611599
public function markRun($dryRun = 1)
	{
		$run = Run::blank();
		$run->set('import_id', $this->get('id'))
			->set('count', $this->get('count'))
			->set('ran_by', User::get('id'))
			->set('ran_at', Date::toSql())
			->set('dry_run', $dryRun)
			->save();
	}
563720
public function save($data = null)
    {
        if ($data !== null) {
            $this->content($data);
        }

        $filename = $this->filename;
        $dir = \dirname($filename);

        if (!$this->mkdir($dir)) {
            throw new \RuntimeException('Creating directory failed for ' . $filename);
        }

        try {
            if ($this->handle) {
                $tmp = true;
                // As we are using non-truncating locking, make sure that the file is empty before writing.
                if (@ftruncate($this->handle, 0) === false || @fwrite($this->handle, $this->raw()) === false) {
                    // Writing file failed, throw an error.
                    $tmp = false;
                }
            } else {
                // Create file with a temporary name and rename it to make the save action atomic.
                $tmp = $this->tempname($filename);
                if (file_put_contents($tmp, $this->raw()) === false) {
                    $tmp = false;
                } elseif (@rename($tmp, $filename) === false) {
                    @unlink($tmp);
                    $tmp = false;
                }
            }
        } catch (\Exception $e) {
            $tmp = false;
        }

        if ($tmp === false) {
            throw new \RuntimeException('Failed to save file ' . $filename);
        }

        // Touch the directory as well, thus marking it modified.
        @touch($dir);
    }
1167870
public function save($runValidation = true, $attributes = null)
    {
        if (parent::save($runValidation, $attributes)) {
            return true;
        } else {
            $event = new ModelEvent();
            $this->trigger(static::EVENT_AFTER_SAVE_FAIL, $event);

            return false;
        }
    }
971950
public function boostAction($run = false)
    {
        $configurationService = $this->objectManager->get(ConfigurationService::class);
        $queueRepository = $this->objectManager->get(QueueRepository::class);
        if ($run) {
            $items = $queueRepository->findOpen(10);
            $queueService = GeneralUtility::makeInstance(QueueService::class);
            try {
                foreach ($items as $item) {
                    $queueService->runSingleRequest($item);
                }
            } catch (\Exception $ex) {
            }

            $this->addFlashMessage('Run ' . \count($items) . ' entries', 'Runner', FlashMessage::OK, true);
        }
        $this->view->assignMultiple([
            'enable' => (bool)$configurationService->get('boostMode'),
            'open' => \count($queueRepository->findOpen(99999999)),
            'old' => \count($queueRepository->findOld()),
        ]);
    }
464061
private function setSaveHandler() {

		if (PHP_VERSION_ID >= 50400) {

			$this->storageEngine = new NativeSessionWrapper();

			if(!session_set_save_handler($this->storageEngine, FALSE)) {
				throw new \RuntimeException('Could not  set session save handler.');
			}

		}

	}
980225
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setIO($input, $output);
        parent::doRun($input, $output);
    }
1186390
public function save(array $options = null)
    {
        try {
            parent::save($options);
        }
        catch (Exception $ex) {
            $this->throwHalcyonSaveException($ex);
        }
    }
948918
private function createSavegame()
    {
        // the current process will become the savegame
        $this->savegame = \posix_getpid();

        $pid = \pcntl_fork();
        if ($pid < 0) {
            throw new \RuntimeException('Unable to create savegame fork');
        } elseif ($pid > 0) {
            // we're the savegame now... let's wait and see what happens
            \pcntl_waitpid($pid, $status);

            // worker exited cleanly, let's bail
            if (!\pcntl_wexitstatus($status)) {
                \posix_kill(\posix_getpid(), SIGKILL);
            }

            // worker didn't exit cleanly, we'll need to have another go
            $this->createSavegame();
        }
    }
755651
public function doRun(InputInterface $input, OutputInterface $output)
    {
        if (!$this->commandsRegistered) {
            $this->registerCommands();

            $this->commandsRegistered = true;
        }

        return parent::doRun($input, $output);
    }
263704
public function save(Data $data)
    {
        if ($this->isReadonly()) {
            throw new \RuntimeException($this->class . ' is readonly');
        }

        $is_fresh = $data->isFresh();
        if (!$is_fresh && !$data->isDirty()) {
            return true;
        }

        $this->__before('save', $data);

        $result = $is_fresh ? $this->insert($data) : $this->update($data);
        if (!$result) {
            throw new \RuntimeException($this->class . ' save failed');
        }

        $this->__after('save', $data);

        return true;
    }
84823
public function start(): self
    {
        if (!$this->url) {
            throw new \RuntimeException("Please the property 'url' and 'saveAs'.", -1);
        }

        // default save to current dir.
        if (!$save = $this->saveAs) {
            $save = \getcwd() . '/' . \basename($this->url);
            // reset
            $this->saveAs = $save;
        }

        $ctx = \stream_context_create();

        // register stream notification callback
        \stream_context_set_params($ctx, [
            'notification' => [$this, 'progressShow']
        ]);

        Cli::write("Download: {$this->url}\nSave As: {$save}\n");

        $fp = \fopen($this->url, 'rb', false, $ctx);

        if (\is_resource($fp) && \file_put_contents($save, $fp)) {
            Cli::write("\nDone!");
        } else {
            $err = \error_get_last();
            Cli::stderr("\nErr.rrr..orr...\n {$err['message']}\n", true, -1);
        }

        // close resource
        if (\is_resource($fp)) {
            \fclose($fp);
        }

        $this->fileSize = null;
        return $this;
    }
853527
public function save($runValidation=true)
    {
        // if (empty($this->_writeProperties))
        //     return false;
        
        // ORM status distinguishing
        if (!$this->_selfCondition) {

            // Event
            if (!$this->beforeSave(true)) {
                return false;
            }

            $result = $this->insert($this->_writeProperties, $runValidation);
            // Change this ActiveRecord to update mode
            if ($result) {
                // ORM handling
                $this->_readProperties = $this->_writeProperties;
                $insertID =  $this->getLastInsertID();
                $this->_readProperties[$this->primaryKey] = $insertID;
                $this->_selfCondition = $insertID;
                // Event
                $this->afterSave(true, $this->_readProperties);
                // Reset properties
                $this->_writeProperties = [];
            }

        } else {

            // Event
            if (!$this->beforeSave(false)) {
                return false;
            }
            
            $result = ($this->_writeProperties) ? $this->update($this->_writeProperties, $this->_selfCondition, $runValidation) : true;
            // Check the primary key is changed
            if ($result) {

                // Primary key condition to ensure single query result 
                if (isset($this->_writeProperties[$this->primaryKey])) {
                    $this->_selfCondition = $this->_writeProperties[$this->primaryKey];
                }
                $this->_readProperties = array_merge($this->_readProperties, $this->_writeProperties);
                // Event
                $this->afterSave(true, $this->_readProperties);
                // Reset properties
                $this->_writeProperties = [];
            }
        }
        
        return $result;
    }
403884
private function setUp($class, Run $run)
    {
        if (!$class) {
            $run->writeOutput("Missing `class` parameter on {$this->jobModel->id} job")
                ->setResult(Run::RESULT_FAILED);

            return false;
        }

        if (!class_exists($class)) {
            $run->writeOutput("$class does not exist")
                ->setResult(Run::RESULT_FAILED);

            return false;
        }

        $job = new $class();

        // inject the DI container if needed
        if (method_exists($job, 'setApp')) {
            $job->setApp($this->jobModel->getApp());
        }

        return $job;
    }