mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
Maintain plugin state
This commit is contained in:
@@ -101,8 +101,7 @@ class Test extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$tool = new TrackerRepository();
|
$result = \Nexus\Plugin\Plugin::listEnabled();
|
||||||
$result = $tool->checkStatus();
|
|
||||||
dd($result);
|
dd($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ namespace App\Console;
|
|||||||
|
|
||||||
use App\Jobs\CheckCleanup;
|
use App\Jobs\CheckCleanup;
|
||||||
use App\Jobs\CheckQueueFailedJobs;
|
use App\Jobs\CheckQueueFailedJobs;
|
||||||
|
use App\Jobs\MaintainPluginState;
|
||||||
|
use App\Jobs\ManagePlugin;
|
||||||
use App\Utils\ThirdPartyJob;
|
use App\Utils\ThirdPartyJob;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Console\Scheduling\Event;
|
use Illuminate\Console\Scheduling\Event;
|
||||||
@@ -43,6 +45,7 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command('torrent:load_pieces_hash')->dailyAt("01:00")->withoutOverlapping();
|
$schedule->command('torrent:load_pieces_hash')->dailyAt("01:00")->withoutOverlapping();
|
||||||
$schedule->job(new CheckQueueFailedJobs())->everySixHours()->withoutOverlapping();
|
$schedule->job(new CheckQueueFailedJobs())->everySixHours()->withoutOverlapping();
|
||||||
$schedule->job(new ThirdPartyJob())->everyMinute()->withoutOverlapping();
|
$schedule->job(new ThirdPartyJob())->everyMinute()->withoutOverlapping();
|
||||||
|
$schedule->job(new MaintainPluginState())->everyMinute()->withoutOverlapping();
|
||||||
|
|
||||||
$this->registerScheduleCleanup($schedule);
|
$this->registerScheduleCleanup($schedule);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ class TorrentStateResource extends Resource
|
|||||||
Tables\Actions\EditAction::make()->after(function () {
|
Tables\Actions\EditAction::make()->after(function () {
|
||||||
do_log("cache_del: global_promotion_state");
|
do_log("cache_del: global_promotion_state");
|
||||||
NexusDB::cache_del(Setting::TORRENT_GLOBAL_STATE_CACHE_KEY);
|
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(),
|
// Tables\Actions\DeleteAction::make(),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,16 @@ class Plugin
|
|||||||
return !empty(self::$providers[$name]['providers']);
|
return !empty(self::$providers[$name]['providers']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function listEnabled(): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
//plugins are more exactly
|
||||||
|
foreach (self::$plugins as $id => $plugin) {
|
||||||
|
$result[$id] = 1;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getById($id) :BasePlugin|null
|
public static function getById($id) :BasePlugin|null
|
||||||
{
|
{
|
||||||
return self::$plugins[$id] ?? null;
|
return self::$plugins[$id] ?? null;
|
||||||
|
|||||||
Reference in New Issue
Block a user