示例#1
0
 /**
  * 保存记录
  *
  * @param Command $commandObj
  * @param $task_id
  * @param $action
  * @param $duration
  * @return mixed
  */
 public static function saveRecord(Command $commandObj, $task_id, $action, $duration)
 {
     $record = new static();
     $record->attributes = ['user_id' => \Yii::$app->user->id, 'task_id' => $task_id, 'status' => (int) $commandObj->getExeStatus(), 'action' => $action, 'created_at' => time(), 'command' => var_export($commandObj->getExeCommand(), true), 'memo' => var_export($commandObj->getExeLog(), true), 'duration' => $duration];
     //        file_put_contents('/tmp/xx', var_export($record->attributes, true).PHP_EOL.PHP_EOL, 8);
     return $record->save();
 }
示例#2
0
 /**
  * 软链接
  */
 private function _link($version = null)
 {
     // 创建链接指向
     $remote = new RemoteCmd();
     $sTime = Command::getMs();
     $ret = $remote->setConfig($this->_config)->link($version);
     // 记录执行日志
     $duration = Command::getMs() - $sTime;
     $ret = Record::saveRecord($remote, $this->_task->id, Record::ACTION_LINK, $duration);
     if (!$ret) {
         throw new \Exception($version ? '回滚失败' : '创建链接指向出错');
     }
     return true;
 }
示例#3
0
 /**
  * 软链接
  */
 private function _link($version = null)
 {
     // 创建链接指向
     $folder = new Folder();
     $sTime = Command::getMs();
     $ret = $folder->setConfig($this->_config)->link($version);
     // 记录执行时间
     $duration = Command::getMs() - $sTime;
     Record::saveRecord($folder, $this->_task->id, Record::ACTION_LINK, $duration);
     if (!$ret) {
         throw new \Exception($version ? '回滚失败' : '创建链接指向出错');
     }
     return true;
 }