mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 16:30:25 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			451 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			451 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package initialize
 | 
						|
 | 
						|
// 系统进程退出终止函数
 | 
						|
type TerminateFunc func()
 | 
						|
 | 
						|
var (
 | 
						|
	terminateFuncs = make([]TerminateFunc, 0)
 | 
						|
)
 | 
						|
 | 
						|
// 添加系统退出终止时执行的函数,由各个模块自行添加
 | 
						|
func AddTerminateFunc(terminateFunc TerminateFunc) {
 | 
						|
	terminateFuncs = append(terminateFuncs, terminateFunc)
 | 
						|
}
 | 
						|
 | 
						|
// 终止进程服务后的一些操作
 | 
						|
func Terminate() {
 | 
						|
	for _, terminateFunc := range terminateFuncs {
 | 
						|
		terminateFunc()
 | 
						|
	}
 | 
						|
}
 |