File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 4
4
"log"
5
5
"os"
6
6
"os/exec"
7
+ "os/signal"
8
+ "syscall"
7
9
8
10
"github.com/moosh3/github-actions-aggregator/pkg/api"
9
11
"github.com/moosh3/github-actions-aggregator/pkg/config"
@@ -36,9 +38,22 @@ func main() {
36
38
githubClient := github .NewClient (cfg .GitHub .AccessToken )
37
39
38
40
workerPool := worker .NewWorkerPool (database , cfg .WorkerPoolSize )
41
+ workerPool .Start ()
39
42
40
43
// Start the API server
41
- api .StartServer (cfg , database , githubClient , workerPool )
44
+ go api .StartServer (cfg , database , githubClient , workerPool )
45
+
46
+ // Set up graceful shutdown
47
+ quit := make (chan os.Signal , 1 )
48
+ signal .Notify (quit , syscall .SIGINT , syscall .SIGTERM )
49
+ <- quit
50
+
51
+ log .Println ("Shutting down server..." )
52
+
53
+ // Stop the worker pool
54
+ workerPool .Stop ()
55
+
56
+ log .Println ("Server exiting" )
42
57
}
43
58
44
59
func runMigrations () error {
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ func GetWorkflowStats(c *gin.Context) {
74
74
c .JSON (http .StatusBadRequest , gin.H {"error" : "start_time must be before end_time" })
75
75
return
76
76
}
77
+
77
78
// Initialize counters
78
79
totalRuns := len (runs )
79
80
successCount := 0
@@ -125,5 +126,4 @@ func GetWorkflowStats(c *gin.Context) {
125
126
"start_time" : startTime .Format (time .RFC3339 ),
126
127
"end_time" : endTime .Format (time .RFC3339 ),
127
128
})
128
-
129
129
}
You can’t perform that action at this time.
0 commit comments