Page MenuHomePhorge

D1285.1775524935.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D1285.1775524935.diff

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 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+
+class DBPing extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'db:ping {--wait}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Ping the database [and wait for it to respond]';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ if ($this->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;
+ }
+ }
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 7, 1:22 AM (11 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822807
Default Alt Text
D1285.1775524935.diff (2 KB)

Event Timeline