大佬教程收集整理的这篇文章主要介绍了golang对正在运行的二进制文件/进程执行命令,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
例如:
@H_549_9@myapp start -debug // starts a server myapp reload -gracefull // stops the app gracefully
现在我需要发送os信号通知我的服务器执行正常关机
kill -QUIT pid kill -USR2 pid
我希望我的问题很清楚
日Thnx
看看os/signal
套餐.
// Set up chAnnel on which to send signal notifications. // We must use a buffered chAnnel or risk missing the signal // if we're not ready to receive when the signal is sent. c := make(chan os.Signal,1) signal.Notify(c,os.Interrupt,os.Kill) // Block until a signal is received. s := <-c fmt.Println("Got signal:",s)
发送信号
要查看如何发送信号,请查看signal_test.go
,它使用syscall
.例如:
// Send this process a SIGHUP t.Logf("sighup...") syscall.Kill(syscall.Getpid(),syscall.SIGHUp) waitSig(t,c,syscall.SIGHUp)
以上是大佬教程为你收集整理的golang对正在运行的二进制文件/进程执行命令全部内容,希望文章能够帮你解决golang对正在运行的二进制文件/进程执行命令所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。