refactor(docker): migrate service startup from Artisan commands to shell scripts
Remove custom Artisan console commands (Horizon, Nightwatch, Scheduler) and refactor service startup logic directly into s6-overlay shell scripts. Check environment variables from .env instead of routing through Laravel config. Services now sleep when disabled instead of exiting immediately. Both development and production environments updated consistently.
This commit is contained in:
parent
e39678aea5
commit
9b0088072c
9 changed files with 46 additions and 117 deletions
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Horizon extends Command
|
||||
{
|
||||
protected $signature = 'start:horizon';
|
||||
|
||||
protected $description = 'Start Horizon';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if (config('constants.horizon.is_horizon_enabled')) {
|
||||
$this->info('Horizon is enabled on this server.');
|
||||
$this->call('horizon');
|
||||
exit(0);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Nightwatch extends Command
|
||||
{
|
||||
protected $signature = 'start:nightwatch';
|
||||
|
||||
protected $description = 'Start Nightwatch';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if (config('constants.nightwatch.is_nightwatch_enabled')) {
|
||||
$this->info('Nightwatch is enabled on this server.');
|
||||
$this->call('nightwatch:agent');
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Scheduler extends Command
|
||||
{
|
||||
protected $signature = 'start:scheduler';
|
||||
|
||||
protected $description = 'Start Scheduler';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if (config('constants.horizon.is_scheduler_enabled')) {
|
||||
$this->info('Scheduler is enabled on this server.');
|
||||
$this->call('schedule:work');
|
||||
exit(0);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
#!/command/execlineb -P
|
||||
#!/bin/sh
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:horizon
|
||||
}
|
||||
if grep -qE '^HORIZON_ENABLED=false' .env 2>/dev/null; then
|
||||
echo "horizon: disabled, sleeping."
|
||||
exec sleep infinity
|
||||
fi
|
||||
|
||||
echo "horizon: enabled, starting..."
|
||||
exec php artisan horizon
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
#!/command/execlineb -P
|
||||
#!/bin/sh
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:nightwatch
|
||||
}
|
||||
if grep -qE '^NIGHTWATCH_ENABLED=true' .env 2>/dev/null; then
|
||||
echo "nightwatch-agent: enabled, starting..."
|
||||
exec php artisan nightwatch:agent
|
||||
fi
|
||||
|
||||
echo "nightwatch-agent: disabled, sleeping."
|
||||
exec sleep infinity
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
#!/command/execlineb -P
|
||||
#!/bin/sh
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:scheduler
|
||||
}
|
||||
|
||||
if grep -qE '^SCHEDULER_ENABLED=false' .env 2>/dev/null; then
|
||||
echo "scheduler-worker: disabled, sleeping."
|
||||
exec sleep infinity
|
||||
fi
|
||||
|
||||
echo "scheduler-worker: enabled, starting..."
|
||||
exec php artisan schedule:work
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#!/command/execlineb -P
|
||||
#!/bin/sh
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:horizon
|
||||
}
|
||||
|
||||
if grep -qE '^HORIZON_ENABLED=false' .env 2>/dev/null; then
|
||||
echo "horizon: disabled, sleeping."
|
||||
exec sleep infinity
|
||||
fi
|
||||
|
||||
echo "horizon: enabled, starting..."
|
||||
exec php artisan horizon
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#!/command/execlineb -P
|
||||
#!/bin/sh
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:nightwatch
|
||||
}
|
||||
|
||||
if grep -qE '^NIGHTWATCH_ENABLED=true' .env 2>/dev/null; then
|
||||
echo "nightwatch-agent: enabled, starting..."
|
||||
exec php artisan nightwatch:agent
|
||||
fi
|
||||
|
||||
echo "nightwatch-agent: disabled, sleeping."
|
||||
exec sleep infinity
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
#!/command/execlineb -P
|
||||
#!/bin/sh
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:scheduler
|
||||
}
|
||||
|
||||
if grep -qE '^SCHEDULER_ENABLED=false' .env 2>/dev/null; then
|
||||
echo "scheduler-worker: disabled, sleeping."
|
||||
exec sleep infinity
|
||||
fi
|
||||
|
||||
echo "scheduler-worker: enabled, starting..."
|
||||
exec php artisan schedule:work
|
||||
|
|
|
|||
Loading…
Reference in a new issue