自动更新管控端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
716 B

package sys
import (
"fmt"
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
)
type Closer interface {
Close()
}
// 获取程序运行路径
func CurrentDirectory() string {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
fmt.Errorf(err.Error())
}
return strings.Replace(dir, "\\", "/", -1)
}
func WaitCloseSignals() {
signals := make(chan os.Signal, 1)
signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
<-signals
}
func WaitCloseSignalsAndRelease(closer Closer) {
signals := make(chan os.Signal, 1)
signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
<-signals
closer.Close()
}