Skip to content

✨ Add scheduled automatic plugin updates#218

Merged
Nlkomaru merged 3 commits intomainfrom
feature/173-scheduled-auto-update
Mar 10, 2026
Merged

✨ Add scheduled automatic plugin updates#218
Nlkomaru merged 3 commits intomainfrom
feature/173-scheduled-auto-update

Conversation

@Nlkomaru
Copy link
Member

Summary

Closes #173

  • cron式によるプラグイン自動更新スケジューラーを追加
  • /mpm update --dry-run コマンドを追加(更新チェックのみ、実行なし)
  • サーバー起動時の更新チェック機能を追加(通知のみ、更新なし)

主な変更点

新規ファイル

  • ScheduleConfig.kt - スケジュール設定データクラス(enabled, cron, checkOnStartup, dryRun)
  • UpdateScheduler.kt - スケジューラーインターフェース(start/stop/restart)
  • UpdateSchedulerImpl.kt - cron-utilsを使ったスケジューラー実装

変更ファイル

  • GlobalSettings.kt - schedule: ScheduleConfig フィールド追加
  • MpmError.kt - UpdateInProgress エラー追加(並行更新防止)
  • PluginUpdateServiceImpl.kt - Mutex による並行更新防止
  • UpdateCommand.kt - --dry-run スイッチ追加、ロック状態フィルタ
  • ReloadCommand.kt - reload時にスケジューラーを再起動
  • Mpm.kt - Koin登録 + onEnable/onDisableでスケジューラー起動/停止

設定例

{
  "settings": {
    "schedule": {
      "enabled": true,
      "cron": "0 4 * * *",
      "checkOnStartup": true,
      "dryRun": false
    }
  }
}

安全性

  • nextExecution() で次回実行時刻を正確に計算(ポーリング方式ではない)
  • AtomicLong による世代管理で restart 時の旧タスク混入を防止
  • Mutex による全更新操作の排他制御(スケジューラー/コマンドの競合回避)
  • メタデータ読み込み失敗は unknown 分類で警告表示(誤判定防止)
  • ロック済みプラグインは dry-run でも正確にスキップ表示

Test plan

  • schedule.enabled: true でサーバー起動 → 起動時チェックが動作すること
  • cron式のタイミングで自動更新が実行されること
  • dryRun: true で更新チェックのみ行われること
  • /mpm update --dry-run で更新プレビューが表示されること
  • /mpm reload でスケジュール設定が即座に反映されること
  • スケジューラーとコマンドの同時実行で "already in progress" エラーが返ること
  • ロック済みプラグインが dry-run/スケジュール更新で正しくスキップされること

Add cron-based scheduled auto-update with dry-run mode and startup check.
@github-actions
Copy link
Contributor

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35a4b38e38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +260 to +262
if (updatableInfos.isEmpty()) {
plugin.logger.info("[Scheduled/Dry-run] All plugins are up to date.")
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid claiming plugins are up to date in dry-run

In scheduled dry-run mode, this branch logs All plugins are up to date whenever updatableInfos is empty, even if there are outdated plugins in lockedInfos or unknownInfos. This produces contradictory output ("up to date" plus "skipped/failed" entries) and can mislead operators into thinking no action is needed when updates are actually pending but blocked. Use the same condition as startup check (all three lists empty) before emitting the "up to date" message.

Useful? React with 👍 / 👎.

Check locked and unknown lists alongside updatable before claiming
all plugins are up to date in scheduled dry-run mode.
@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@Nlkomaru Nlkomaru merged commit 0ed989e into main Mar 10, 2026
9 checks passed
@Nlkomaru Nlkomaru deleted the feature/173-scheduled-auto-update branch March 10, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add scheduled automatic plugin updates

1 participant