Skip to content

Commit 962a1a4

Browse files
committed
Merge pull request #116 from dancryer/master
Fix database timeout issue with worker daemon.
2 parents d511d69 + 6bfa25e commit 962a1a4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.phpci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ complete:
6161
env:
6262
CODECLIMATE_REPO_TOKEN: "f5222770741fef12c55315f61a267c8a615908e511241618ce171129e8217e63"
6363
shell:
64-
- "php /var/www/PHPCI/vendor/bin/phpunit --coverage-clover %BUILD_PATH%/storage/coverage/clover.xml -c %BUILD_PATH%/phpunit.xml %BUILD_PATH%/tests"
65-
- "php /var/www/PHPCI/vendor/bin/test-reporter --coverage-report=%BUILD_PATH%/storage/coverage/clover.xml"
64+
- "php /var/www/PHPCI/latest/vendor/bin/phpunit --coverage-clover %BUILD_PATH%/storage/coverage/clover.xml -c %BUILD_PATH%/phpunit.xml %BUILD_PATH%/tests"
65+
- "php /var/www/PHPCI/latest/vendor/bin/test-reporter --coverage-report=%BUILD_PATH%/storage/coverage/clover.xml"
6666

6767
success:

app/Deployment.php

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\SoftDeletes;
7+
use Illuminate\Support\Facades\App;
8+
use Illuminate\Support\Facades\DB;
79
use Illuminate\Support\Facades\Lang;
810
use REBELinBLUE\Deployer\Contracts\RuntimeInterface;
911
use REBELinBLUE\Deployer\Events\ModelChanged;
@@ -316,4 +318,18 @@ public function getRepoFailureAttribute()
316318
{
317319
return ($this->commit === self::LOADING && $this->status === self::FAILED);
318320
}
321+
322+
/**
323+
* A little hack to reconnect to the database if we're in console mode and trying to find a deployment.
324+
* Should fix the error sending STMT_PREPARE problem that causes deployments to sit "pending" forever.
325+
* @return mixed
326+
*/
327+
public function findOrFail()
328+
{
329+
if (App::runningInConsole()) {
330+
DB::reconnect();
331+
}
332+
333+
return parent::__call('findOrFail', func_get_args());
334+
}
319335
}

0 commit comments

Comments
 (0)