diff --git a/bin/quickstart.sh b/bin/quickstart.sh --- a/bin/quickstart.sh +++ b/bin/quickstart.sh @@ -76,6 +76,7 @@ pushd ${base_dir}/src/ rm -rf database/database.sqlite +./artisan db:ping --wait php -dmemory_limit=512M ./artisan migrate:refresh --seed ./artisan serve popd diff --git a/docker/worker/kolab-worker.sh b/docker/worker/kolab-worker.sh --- a/docker/worker/kolab-worker.sh +++ b/docker/worker/kolab-worker.sh @@ -13,4 +13,6 @@ rm -rf bootstrap/cache/ mkdir -p bootstrap/cache/ +./artisan db:ping --wait + ./artisan queue:work diff --git a/src/app/Console/Commands/DBPing.php b/src/app/Console/Commands/DBPing.php new file mode 100644 --- /dev/null +++ b/src/app/Console/Commands/DBPing.php @@ -0,0 +1,62 @@ +option('wait')) { + while (true) { + try { + $result = DB::select("SELECT 1"); + + if (sizeof($result) > 0) { + break; + } + } catch (\Exception $exception) { + sleep(1); + } + } + } else { + try { + $result = DB::select("SELECT 1"); + return 0; + } catch (\Exception $exception) { + return 1; + } + } + } +}