Maintain plugin state

This commit is contained in:
xiaomlove
2024-11-17 02:44:41 +08:00
parent 631f703055
commit c2e70c9569
5 changed files with 60 additions and 2 deletions

View File

@@ -101,8 +101,7 @@ class Test extends Command
*/
public function handle()
{
$tool = new TrackerRepository();
$result = $tool->checkStatus();
$result = \Nexus\Plugin\Plugin::listEnabled();
dd($result);
}

View File

@@ -4,6 +4,8 @@ namespace App\Console;
use App\Jobs\CheckCleanup;
use App\Jobs\CheckQueueFailedJobs;
use App\Jobs\MaintainPluginState;
use App\Jobs\ManagePlugin;
use App\Utils\ThirdPartyJob;
use Carbon\Carbon;
use Illuminate\Console\Scheduling\Event;
@@ -43,6 +45,7 @@ class Kernel extends ConsoleKernel
$schedule->command('torrent:load_pieces_hash')->dailyAt("01:00")->withoutOverlapping();
$schedule->job(new CheckQueueFailedJobs())->everySixHours()->withoutOverlapping();
$schedule->job(new ThirdPartyJob())->everyMinute()->withoutOverlapping();
$schedule->job(new MaintainPluginState())->everyMinute()->withoutOverlapping();
$this->registerScheduleCleanup($schedule);
}

View File

@@ -66,6 +66,8 @@ class TorrentStateResource extends Resource
Tables\Actions\EditAction::make()->after(function () {
do_log("cache_del: global_promotion_state");
NexusDB::cache_del(Setting::TORRENT_GLOBAL_STATE_CACHE_KEY);
do_log("publish_model_event: global_promotion_state_updated");
publish_model_event("global_promotion_state_updated", 0);
}),
// Tables\Actions\DeleteAction::make(),
])

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Nexus\Database\NexusDB;
use Nexus\Plugin\Plugin;
class MaintainPluginState implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$enabled = Plugin::listEnabled();
$key = "nexus_plugin_enabled";
NexusDB::redis()->del($key);
$nowStr = now()->toDateTimeString();
foreach ($enabled as $name => $value) {
NexusDB::redis()->hSet($key, $name, $nowStr);
}
do_log("$key: " . nexus_json_encode($enabled));
}
}