mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
schedule task log to docker process when running in docker environment
This commit is contained in:
@@ -76,6 +76,7 @@ RUN echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/error-logging.in
|
|||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
ENV LOG_CHANNEL=stderr
|
ENV LOG_CHANNEL=stderr
|
||||||
|
ENV RUNNING_IN_DOCKER=1
|
||||||
|
|
||||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ RUN echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/error-logging.in
|
|||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
ENV LOG_CHANNEL=stderr
|
ENV LOG_CHANNEL=stderr
|
||||||
|
ENV RUNNING_IN_DOCKER=1
|
||||||
|
|
||||||
# 复制入口脚本
|
# 复制入口脚本
|
||||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|||||||
+15
-15
@@ -35,23 +35,23 @@ class Kernel extends ConsoleKernel
|
|||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
$schedule->command('cache:prune-stale-tags')->hourly();
|
$schedule->command('cache:prune-stale-tags')->hourly();
|
||||||
$schedule->command('exam:assign_cronjob')->everyMinute()->withoutOverlapping();
|
$schedule->command('exam:assign_cronjob')->everyMinute();
|
||||||
$schedule->command('exam:checkout_cronjob')->everyFiveMinutes()->withoutOverlapping();
|
$schedule->command('exam:checkout_cronjob')->everyFiveMinutes();
|
||||||
$schedule->command('exam:update_progress --bulk=1')->hourly()->withoutOverlapping();
|
$schedule->command('exam:update_progress --bulk=1')->hourly();
|
||||||
$schedule->command('backup:cronjob')->everyMinute()->withoutOverlapping();
|
$schedule->command('backup:cronjob')->everyMinute();
|
||||||
$schedule->command('hr:update_status')->everyTenMinutes()->withoutOverlapping();
|
$schedule->command('hr:update_status')->everyTenMinutes();
|
||||||
$schedule->command('hr:update_status --ignore_time=1')->hourly()->withoutOverlapping();
|
$schedule->command('hr:update_status --ignore_time=1')->hourly();
|
||||||
$schedule->command('user:delete_expired_token')->dailyAt('04:00')->withoutOverlapping();
|
$schedule->command('user:delete_expired_token')->dailyAt('04:00');
|
||||||
$schedule->command('claim:settle')->hourly()->when(function () {
|
$schedule->command('claim:settle')->hourly()->when(function () {
|
||||||
return Carbon::now()->format('d') == '01';
|
return Carbon::now()->format('d') == '01';
|
||||||
})->withoutOverlapping();
|
});
|
||||||
$schedule->command('meilisearch:import')->weeklyOn(1, "03:00")->withoutOverlapping();
|
$schedule->command('meilisearch:import')->weeklyOn(1, "03:00");
|
||||||
$schedule->command('torrent:load_pieces_hash')->dailyAt("01:00")->withoutOverlapping();
|
$schedule->command('torrent:load_pieces_hash')->dailyAt("01:00");
|
||||||
$schedule->job(new CheckQueueFailedJobs())->everySixHours()->withoutOverlapping();
|
$schedule->job(new CheckQueueFailedJobs())->everySixHours();
|
||||||
$schedule->job(new ThirdPartyJob())->everyMinute()->withoutOverlapping();
|
$schedule->job(new ThirdPartyJob())->everyMinute();
|
||||||
$schedule->job(new MaintainPluginState())->everyMinute()->withoutOverlapping();
|
$schedule->job(new MaintainPluginState())->everyMinute();
|
||||||
$schedule->job(new UpdateIsSeedBoxFromUserRecordsCache())->everySixHours()->withoutOverlapping();
|
$schedule->job(new UpdateIsSeedBoxFromUserRecordsCache())->everySixHours();
|
||||||
$schedule->job(new CheckCleanup())->everyFifteenMinutes()->withoutOverlapping();
|
$schedule->job(new CheckCleanup())->everyFifteenMinutes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ use App\Http\Middleware\Locale;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Support\Assets\Css;
|
use Filament\Support\Assets\Css;
|
||||||
use Filament\Support\Facades\FilamentAsset;
|
use Filament\Support\Facades\FilamentAsset;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Illuminate\Console\Events\ScheduledTaskStarting;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
@@ -44,6 +46,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
if (env('APP_ENV') == "production" && in_array($forceScheme, ['https', 'http'])) {
|
if (env('APP_ENV') == "production" && in_array($forceScheme, ['https', 'http'])) {
|
||||||
URL::forceScheme($forceScheme);
|
URL::forceScheme($forceScheme);
|
||||||
}
|
}
|
||||||
|
$this->customScheduleTask();
|
||||||
|
|
||||||
Filament::serving(function () {
|
Filament::serving(function () {
|
||||||
Filament::registerNavigationGroups([
|
Filament::registerNavigationGroups([
|
||||||
@@ -64,4 +67,26 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
do_action('nexus_boot');
|
do_action('nexus_boot');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function customScheduleTask(): void
|
||||||
|
{
|
||||||
|
if (!isRunningInConsole()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/** @var Dispatcher $eventDispatcher */
|
||||||
|
$eventDispatcher = $this->app->make(Dispatcher::class);
|
||||||
|
|
||||||
|
$eventDispatcher->listen(
|
||||||
|
events: [ScheduledTaskStarting::class],
|
||||||
|
listener: static function (ScheduledTaskStarting $event): void {
|
||||||
|
$event->task->onOneServer()->withoutOverlapping();
|
||||||
|
// When we are using stterr as output for logs then schedule tasks will not output
|
||||||
|
// any logs due the /dev/null usage. Let's fix this by appending the output to
|
||||||
|
// the docker process.
|
||||||
|
if (getenv("RUNNING_IN_DOCKER") == "1" && $event->task->output === $event->task->getDefaultOutput()) {
|
||||||
|
$event->task->appendOutputTo("/proc/1/fd/1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.0');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.1');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-05-18');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-05-19');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
Reference in New Issue
Block a user