Esempio n. 1
0
 /**
  * 执行远程服务器任务集合
  * 对于目标机器更多的时候是一台机器完成一组命令,而不是每条命令逐台机器执行
  *
  * @param $version
  * @throws \Exception
  */
 private function _updateRemoteServers($version)
 {
     $cmd = [];
     // pre-release task
     if ($preRelease = WalleTask::getRemoteTaskCommand($this->conf->pre_release, $version)) {
         $cmd[] = $preRelease;
     }
     // link
     if ($linkCmd = $this->walleFolder->getLinkCommand($version)) {
         $cmd[] = $linkCmd;
     }
     // post-release task
     if ($postRelease = WalleTask::getRemoteTaskCommand($this->conf->post_release, $version)) {
         $cmd[] = $postRelease;
     }
     $sTime = Command::getMs();
     // run the task package
     $ret = $this->walleTask->runRemoteTaskCommandPackage($cmd);
     // 记录执行时间
     $duration = Command::getMs() - $sTime;
     Record::saveRecord($this->walleTask, $this->task->id, Record::ACTION_UPDATE_REMOTE, $duration);
     if (!$ret) {
         throw new \Exception('全量更新服务器出错');
     }
     return true;
 }
Esempio n. 2
0
 /**
  * 同步完所有目标机器时触发任务
  * 所有目标机器都部署完毕之后,做一些清理工作,如删除缓存、重启服务(nginx、php、task)
  *
  * @return bool
  * @throws \Exception
  */
 private function _postRelease()
 {
     $task = new WalleTask();
     $sTime = Command::getMs();
     $task->setConfig($this->conf);
     $ret = $task->postRelease($this->task->link_id);
     // 记录执行时间
     $duration = Command::getMs() - $sTime;
     Record::saveRecord($task, $this->task->id, Record::ACTION_POST_RELEASE, $duration);
     if (!$ret) {
         throw new \Exception('同步代码后置任务操作失败');
     }
     return true;
 }