mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
Maintain plugin state
This commit is contained in:
@@ -101,8 +101,7 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$tool = new TrackerRepository();
|
||||
$result = $tool->checkStatus();
|
||||
$result = \Nexus\Plugin\Plugin::listEnabled();
|
||||
dd($result);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
])
|
||||
|
||||
44
app/Jobs/MaintainPluginState.php
Normal file
44
app/Jobs/MaintainPluginState.php
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user