[PR #6924] [CLOSED] feat(xray): add scheduled periodic core restart in settings #6525

Closed
opened 2026-11-02 04:09:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6924
Author: @Pejman-Yousefi-Official
Created: 10/24/2026
Status: ❌ Closed

Base: main ← Head: feat/xray-scheduled-restart


📝 Commits (3)

  • 0c15aa5 feat(xray): add scheduled periodic core restart in settings
  • b8c73c9 fix(xray): force core restart, validate schedule, and guard min interval
  • 034dbfd style: format Go files with gofumpt

📊 Changes

31 files changed (+393 additions, -16 deletions)

View changed files

📝 docs/public/openapi.json (+18 -2)
📝 frontend/public/openapi.json (+18 -2)
📝 frontend/src/generated/examples.ts (+6 -2)
📝 frontend/src/generated/schemas.ts (+18 -2)
📝 frontend/src/generated/types.ts (+4 -0)
📝 frontend/src/generated/zod.ts (+4 -0)
📝 frontend/src/models/setting.ts (+2 -0)
📝 frontend/src/pages/settings/GeneralTab.tsx (+28 -0)
📝 frontend/src/pages/settings/NotifyTimeField.tsx (+22 -4)
📝 frontend/src/schemas/setting.ts (+2 -0)
📝 internal/web/controller/setting.go (+14 -0)
📝 internal/web/entity/check_valid_test.go (+40 -0)
📝 internal/web/entity/entity.go (+13 -1)
➕ internal/web/job/xray_periodic_restart_job.go (+37 -0)
➕ internal/web/job/xray_periodic_restart_job_test.go (+63 -0)
📝 internal/web/service/setting.go (+18 -0)
📝 internal/web/translation/ar-EG.json (+4 -0)
📝 internal/web/translation/en-US.json (+4 -0)
📝 internal/web/translation/es-ES.json (+4 -0)
📝 internal/web/translation/fa-IR.json (+4 -0)

...and 11 more files

📄 Description

Summary

Adds a configurable scheduled/periodic restart option for the Xray core under Panel Settings -> General, utilizing the panel's modular cron scheduler and schedule picker.

Why

In high-load production servers or networks experiencing connection decay, memory leaks in upstream protocols, or stale DNS/routing sockets, periodically restarting the Xray core (e.g. daily at off-peak hours or weekly) helps maintain optimum performance and connection stability without requiring manual administrator intervention or external system cron jobs.

Type of change

  • New feature
  • Bug fix
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  1. Backend Unit Tests:
    • Added internal/web/service/setting_xray_restart_test.go verifying factory defaults (false, @daily) and persistence of xrayPeriodicRestartEnable and xrayPeriodicRestartCron.
    • Added internal/web/job/xray_periodic_restart_job_test.go verifying safe non-panicking execution of XrayPeriodicRestartJob.
    • Verified TestGetFactoryDefaultsInvariant passes and respects tag contracts.
  2. Dynamic Cron Rescheduling:
    • Verified that changing the cron expression or enabling/disabling the setting immediately updates the active cron job via reloadXrayPeriodicRestartFunc without requiring a panel daemon restart.
  3. Frontend & OpenAPI Validation:
    • Ran go run ./tools/openapigen and npm run gen:api to sync OpenAPI schema.
    • Tested UI toggle and cron expression selector (NotifyTimeField) in General settings.
    • Ran npm run lint (0 warnings, 0 errors) and npm run typecheck (tsc --noEmit).

Breaking changes

None. Disabled by default (xrayPeriodicRestartEnable = false), fully backward-compatible with existing databases.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6924 **Author:** [@Pejman-Yousefi-Official](https://github.com/Pejman-Yousefi-Official) **Created:** 10/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/xray-scheduled-restart` --- ### 📝 Commits (3) - [`0c15aa5`](https://github.com/MHSanaei/3x-ui/commit/0c15aa571e32fb06260105855625fbce2f47e238) feat(xray): add scheduled periodic core restart in settings - [`b8c73c9`](https://github.com/MHSanaei/3x-ui/commit/b8c73c9b28769e3c6deee085803caf96368429aa) fix(xray): force core restart, validate schedule, and guard min interval - [`034dbfd`](https://github.com/MHSanaei/3x-ui/commit/034dbfde48fa3aaf267b4f6ba0001e4a635e9aac) style: format Go files with gofumpt ### 📊 Changes **31 files changed** (+393 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `docs/public/openapi.json` (+18 -2) 📝 `frontend/public/openapi.json` (+18 -2) 📝 `frontend/src/generated/examples.ts` (+6 -2) 📝 `frontend/src/generated/schemas.ts` (+18 -2) 📝 `frontend/src/generated/types.ts` (+4 -0) 📝 `frontend/src/generated/zod.ts` (+4 -0) 📝 `frontend/src/models/setting.ts` (+2 -0) 📝 `frontend/src/pages/settings/GeneralTab.tsx` (+28 -0) 📝 `frontend/src/pages/settings/NotifyTimeField.tsx` (+22 -4) 📝 `frontend/src/schemas/setting.ts` (+2 -0) 📝 `internal/web/controller/setting.go` (+14 -0) 📝 `internal/web/entity/check_valid_test.go` (+40 -0) 📝 `internal/web/entity/entity.go` (+13 -1) ➕ `internal/web/job/xray_periodic_restart_job.go` (+37 -0) ➕ `internal/web/job/xray_periodic_restart_job_test.go` (+63 -0) 📝 `internal/web/service/setting.go` (+18 -0) 📝 `internal/web/translation/ar-EG.json` (+4 -0) 📝 `internal/web/translation/en-US.json` (+4 -0) 📝 `internal/web/translation/es-ES.json` (+4 -0) 📝 `internal/web/translation/fa-IR.json` (+4 -0) _...and 11 more files_ </details> ### 📄 Description ## Summary Adds a configurable scheduled/periodic restart option for the Xray core under **Panel Settings -> General**, utilizing the panel's modular cron scheduler and schedule picker. ## Why In high-load production servers or networks experiencing connection decay, memory leaks in upstream protocols, or stale DNS/routing sockets, periodically restarting the Xray core (e.g. daily at off-peak hours or weekly) helps maintain optimum performance and connection stability without requiring manual administrator intervention or external system cron jobs. ## Type of change - [x] New feature - [ ] Bug fix - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [x] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? 1. **Backend Unit Tests:** - Added `internal/web/service/setting_xray_restart_test.go` verifying factory defaults (`false`, `@daily`) and persistence of `xrayPeriodicRestartEnable` and `xrayPeriodicRestartCron`. - Added `internal/web/job/xray_periodic_restart_job_test.go` verifying safe non-panicking execution of `XrayPeriodicRestartJob`. - Verified `TestGetFactoryDefaultsInvariant` passes and respects tag contracts. 2. **Dynamic Cron Rescheduling:** - Verified that changing the cron expression or enabling/disabling the setting immediately updates the active cron job via `reloadXrayPeriodicRestartFunc` without requiring a panel daemon restart. 3. **Frontend & OpenAPI Validation:** - Ran `go run ./tools/openapigen` and `npm run gen:api` to sync OpenAPI schema. - Tested UI toggle and cron expression selector (`NotifyTimeField`) in General settings. - Ran `npm run lint` (0 warnings, 0 errors) and `npm run typecheck` (`tsc --noEmit`). ## Breaking changes None. Disabled by default (`xrayPeriodicRestartEnable = false`), fully backward-compatible with existing databases. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:09:23 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6525
No description provided.