mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 16:41:54 +08:00
- Added functionality to save full metrics periodically and on application shutdown, improving data persistence. - Introduced new database tables for performance metrics, status code history, popular paths, and referer history, enhancing data tracking capabilities. - Updated the GetRecentMetrics function to utilize window functions for more accurate metrics retrieval and ensure non-negative values. - Improved data handling by ensuring empty records are returned instead of null when no metrics are available. These changes significantly enhance the metrics collection and storage process, providing a more robust framework for performance monitoring.
18 lines
230 B
Go
18 lines
230 B
Go
package utils
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
func SetupCloseHandler(callback func()) {
|
|
c := make(chan os.Signal, 2)
|
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
|
go func() {
|
|
<-c
|
|
callback()
|
|
os.Exit(0)
|
|
}()
|
|
}
|