mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-19 00:41:55 +08:00
- Improved the metrics dashboard layout with new styles for better visual presentation, including enhanced chart and control elements. - Added functionality for auto-refreshing metrics and exporting data to CSV, improving user interaction and data accessibility. - Implemented persistent statistics tracking in the collector, allowing for historical data retrieval and better performance monitoring. - Enhanced database operations with optimizations for saving metrics and cleaning up old data, ensuring efficient data management. - Introduced performance metrics tracking, providing insights into average response times and throughput. These changes significantly enhance the usability and functionality of the metrics dashboard, providing a more robust framework for performance monitoring and data analysis.
33 lines
404 B
Go
33 lines
404 B
Go
package utils
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"sync"
|
|
"syscall"
|
|
)
|
|
|
|
func SetupCloseHandler(callback func()) {
|
|
c := make(chan os.Signal, 1)
|
|
done := make(chan bool, 1)
|
|
var once sync.Once
|
|
|
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
|
go func() {
|
|
<-c
|
|
once.Do(func() {
|
|
callback()
|
|
done <- true
|
|
})
|
|
}()
|
|
|
|
go func() {
|
|
select {
|
|
case <-done:
|
|
os.Exit(0)
|
|
case <-c:
|
|
os.Exit(1)
|
|
}
|
|
}()
|
|
}
|