Source of file DNGitFetch.php
Size: 2,001 Bytes - Last Modified: 2021-12-23T10:29:15+00:00
/var/www/docs.ssmods.com/process/src/code/model/jobs/DNGitFetch.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 | <?php class DNGitFetch extends DataObject { /** * * @var array */ private static $db = array( "ResqueToken" => "Varchar(255)", ); /** * * @var array */ private static $has_one = array( "Project" => "DNProject", "Deployer" =>"Member", ); /** * Queue a fetch job */ public function start() { $project = $this->Project(); $log = $this->log(); $args = array( 'projectName' => $project->Name, 'logfile' => $this->logfile(), 'env' => $project->getProcessEnv() ); if(!$this->DeployerID) { $this->DeployerID = Member::currentUserID(); } if($this->DeployerID) { $deployer = $this->Deployer(); $message = sprintf( 'Update repository job for %s initiated by %s (%s)', $project->Name, $deployer->getName(), $deployer->Email ); $log->write($message); } $token = Resque::enqueue('git', 'FetchJob', $args, true); $this->ResqueToken = $token; $this->write(); $message = sprintf('Fetch queued as job %s', $token); $log->write($message); } /** * * @param Member $member * @return bool */ public function canView($member = null) { return $this->Project()->canView($member); } /** * Return a path to the log file. * @return string */ protected function logfile() { return sprintf( '%s.fetch.%s.log', $this->Project()->Name, $this->ID ); } /** * * @return \DeploynautLogFile */ public function log() { return new DeploynautLogFile($this->logfile()); } /** * * @return string */ public function LogContent() { return $this->log()->content(); } /** * * @return string */ public function ResqueStatus() { $status = new Resque_Job_Status($this->ResqueToken); $remap = array( Resque_Job_Status::STATUS_WAITING => "Queued", Resque_Job_Status::STATUS_RUNNING => "Running", Resque_Job_Status::STATUS_FAILED => "Failed", Resque_Job_Status::STATUS_COMPLETE => "Complete", false => "Invalid", ); return $remap[$status->get()]; } } |