feat(system-admin): implement bootstrap for system admin promotion and enhance system settings management

- Added WEKNORA_BOOTSTRAP_SYSTEM_ADMIN_EMAIL environment variable to promote a specified user to system admin on startup.
- Introduced a new bootstrap process in `bootstrap.go` to handle the promotion logic.
- Updated `.env.example` to document the new environment variable and its behavior.
- Created new views for managing system administrators and system settings, including listing, promoting, and revoking admin privileges.
- Enhanced the frontend to reflect the new system admin features, including UI elements for admin management and settings configuration.
- Updated API interfaces to support system admin functionalities, ensuring proper data handling and user management.
This commit is contained in:
wizardchen
2026-05-24 21:38:05 +08:00
committed by lyingbug
parent e6ee87759d
commit 47a183aa65
43 changed files with 3322 additions and 146 deletions
+14
View File
@@ -57,12 +57,17 @@ func main() {
// Build dependency injection container
c := container.BuildContainer(runtime.GetContainer())
// One-shot bootstrap hooks (e.g. promote env-named user to system
// admin). Best-effort: never aborts startup — see bootstrap.go.
runStartupBootstrap(c)
// Run application
err := c.Invoke(func(
cfg *config.Config,
router *gin.Engine,
tracer *tracing.Tracer,
resourceCleaner interfaces.ResourceCleaner,
systemSettingSvc interfaces.SystemSettingService,
) error {
// Create HTTP server
server := &http.Server{
@@ -77,6 +82,15 @@ func main() {
ctx, done := context.WithCancel(context.Background())
// Start the system_settings pubsub subscriber. Runs in its own
// goroutine and exits when ctx is cancelled at shutdown. Best-
// effort: an error here only warns (Redis may legitimately be
// disabled in lite-mode deployments — the service no-ops in
// that case anyway).
if err := systemSettingSvc.SubscribeRedis(ctx); err != nil {
logger.Warnf(ctx, "[system_settings] subscribe failed: %v", err)
}
signals := make(chan os.Signal, 1)
signal.Notify(signals, shutdownSignals...)
go func() {