func TestCmdConsole() { fmt.Println("children init finish") kmgConsole.WaitForExit() fmt.Println("children after WaitForExit") time.Sleep(time.Second) fmt.Println("children after sleep") }
func cmd() { fmt.Println("children init finish") kmgConsole.WaitForExit() kmgFile.MustWriteFile("/tmp/2.log", []byte(time.Now().String())) fmt.Println("children after WaitForExit") time.Sleep(time.Second) fmt.Println("children after sleep") }
func main() { os.Stderr.WriteString("Stderr: start\n") kmgFile.MustMkdirAll("/var/ServiceTester") pid := os.Getpid() logFilePath = filepath.Join("/var/ServiceTester", time.Now().Format(kmgTime.FormatFileName)+"_"+strconv.Itoa(pid)+".log") log("start") go func() { for { time.Sleep(time.Second) log("running") } }() kmgConsole.WaitForExit() log("stop") }
func main() { // run the server in a new thread. // 在一个新线程里面一直运行服务器. kmgRadius.RunServer(":1812", []byte("sEcReT"), kmgRadius.Handler{ Auth: func(username string) (password string, exist bool) { if username != "a" { return "", false } return "b", true }, AcctStart: func(req kmgRadius.AcctRequest) { kmgDebug.Println("start", req) }, AcctUpdate: func(req kmgRadius.AcctRequest) { kmgDebug.Println("update", req) }, AcctStop: func(req kmgRadius.AcctRequest) { kmgDebug.Println("stop", req) }, }) // wait for the system sign or ctrl-c to close the process. // 等待系统信号或者ctrl-c 关闭进程 kmgConsole.WaitForExit() }