-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (35 loc) · 889 Bytes
/
main.go
File metadata and controls
42 lines (35 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// File: main.go
package main
import (
"fmt"
"os"
"vault.module/cmd"
"vault.module/internal/errors"
"vault.module/internal/security"
)
func main() {
// Initialize the graceful shutdown manager
shutdownManager := security.GetManager()
// Defer shutdown to ensure cleanup happens even on normal exit
defer func() {
if !shutdownManager.IsShutdown() {
shutdownManager.Shutdown()
}
}()
// Execute the root command and check for errors.
if err := cmd.Execute(); err != nil {
// Use centralized error handling
if errors.DefaultHandler != nil {
errorMsg := errors.FormatForUser(err)
fmt.Fprintln(os.Stderr, "Error:", errorMsg)
} else {
// Fallback if error handler not initialized
fmt.Fprintln(os.Stderr, "Error:", err)
}
// Ensure cleanup happens before exit
if !shutdownManager.IsShutdown() {
shutdownManager.Shutdown()
}
os.Exit(1)
}
}