feat: 修复了文件被意外ignore
This commit is contained in:
36
cmd/server/main.go
Normal file
36
cmd/server/main.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 初始化应用程序(Wire 自动生成)
|
||||
app, err := InitializeApp()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to initialize app: %v", err)
|
||||
}
|
||||
|
||||
// 启动应用程序
|
||||
ctx := context.Background()
|
||||
if err := app.Start(ctx); err != nil {
|
||||
log.Fatalf("failed to start app: %v", err)
|
||||
}
|
||||
|
||||
// 优雅关闭
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-quit
|
||||
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if err := app.Stop(shutdownCtx); err != nil {
|
||||
log.Printf("Error during shutdown: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user