Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117912748
D1285.1775400461.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D1285.1775400461.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 2:47 PM (1 d, 5 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822807
Default Alt Text
D1285.1775400461.diff (2 KB)
Attached To
Mode
D1285: Add a command db:ping and then use it
Attached
Detach File
Event Timeline