| @@ 154-182 (lines=29) @@ | ||
| 151 | /** |
|
| 152 | * Check status of current snapshot |
|
| 153 | */ |
|
| 154 | protected function continueSnapshot() { |
|
| 155 | $this->log("Checking status of {$this->Title}..."); |
|
| 156 | ||
| 157 | // Skip snapshot for dry run |
|
| 158 | if($this->Pipeline()->DryRun) { |
|
| 159 | $this->log("[Skipped] Checking progress of snapshot backup"); |
|
| 160 | return $this->startDeploy(); |
|
| 161 | } |
|
| 162 | ||
| 163 | // Skip snapshot for environments with no build |
|
| 164 | if(!$this->Pipeline()->Environment()->CurrentBuild()) { |
|
| 165 | return $this->startDeploy(); |
|
| 166 | } |
|
| 167 | ||
| 168 | // Get related snapshot |
|
| 169 | $snapshot = $this->Pipeline()->PreviousSnapshot(); |
|
| 170 | if(empty($snapshot) || !$snapshot->exists()) { |
|
| 171 | $this->log("Missing snapshot for in-progress {$this->Title}"); |
|
| 172 | $this->markFailed(); |
|
| 173 | return false; |
|
| 174 | } |
|
| 175 | ||
| 176 | // Check finished state |
|
| 177 | $status = $snapshot->ResqueStatus(); |
|
| 178 | if($this->checkResqueStatus($status)) { |
|
| 179 | // After snapshot is done, switch to doing deployment |
|
| 180 | return $this->startDeploy(); |
|
| 181 | } |
|
| 182 | } |
|
| 183 | ||
| 184 | /** |
|
| 185 | * Check status of deployment and finish task if complete, or fail if timedout |
|
| @@ 189-213 (lines=25) @@ | ||
| 186 | * |
|
| 187 | * @return boolean |
|
| 188 | */ |
|
| 189 | protected function continueDeploy() { |
|
| 190 | $this->log("Checking status of {$this->Title}..."); |
|
| 191 | ||
| 192 | // Skip deployment for dry run |
|
| 193 | if($this->Pipeline()->DryRun) { |
|
| 194 | $this->log("[Skipped] Checking progress of deployment"); |
|
| 195 | $this->finish(); |
|
| 196 | return !$this->isFailed(); |
|
| 197 | } |
|
| 198 | ||
| 199 | // Get related deployment |
|
| 200 | $deployment = $this->Pipeline()->CurrentDeployment(); |
|
| 201 | if(empty($deployment) || !$deployment->exists()) { |
|
| 202 | $this->log("Missing deployment for in-progress {$this->Title}"); |
|
| 203 | $this->markFailed(); |
|
| 204 | return false; |
|
| 205 | } |
|
| 206 | ||
| 207 | // Check finished state |
|
| 208 | $status = $deployment->ResqueStatus(); |
|
| 209 | if($this->checkResqueStatus($status)) { |
|
| 210 | $this->finish(); |
|
| 211 | } |
|
| 212 | return !$this->isFailed(); |
|
| 213 | } |
|
| 214 | ||
| 215 | /** |
|
| 216 | * Check the status of a resque sub-task |
|
| @@ 169-195 (lines=27) @@ | ||
| 166 | /** |
|
| 167 | * Check status of current snapshot |
|
| 168 | */ |
|
| 169 | protected function continueRevertDatabase() { |
|
| 170 | $this->log("Checking status of {$this->Title}..."); |
|
| 171 | ||
| 172 | // Skip snapshot for dry run |
|
| 173 | if($this->Pipeline()->DryRun) { |
|
| 174 | $this->log("[Skipped] Checking progress of snapshot restore"); |
|
| 175 | return $this->finish(); |
|
| 176 | } |
|
| 177 | ||
| 178 | // Get related snapshot |
|
| 179 | $transfer = $this->RollbackDatabase(); |
|
| 180 | if(empty($transfer) || !$transfer->exists()) { |
|
| 181 | $this->log("Missing database transfer for in-progress {$this->Title}"); |
|
| 182 | $this->markFailed(); |
|
| 183 | return false; |
|
| 184 | } |
|
| 185 | ||
| 186 | // Check finished state |
|
| 187 | $status = $transfer->ResqueStatus(); |
|
| 188 | if($this->checkResqueStatus($status)) { |
|
| 189 | // Re-enable the site by disabling the maintenance, since the DB restored successfully |
|
| 190 | $this->Pipeline()->Environment()->disableMaintenance($this->Pipeline()->getLogger()); |
|
| 191 | ||
| 192 | // After revert is complete we are done |
|
| 193 | return $this->finish(); |
|
| 194 | } |
|
| 195 | } |
|
| 196 | ||
| 197 | /** |
|
| 198 | * Check status of deployment and finish task if complete, or fail if timedout |
|