You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt"
"os"
"time"
"github.com/gogf/gf/v2/os/gproc"
)
func signalHandlerForMQ(sig os.Signal) {
fmt.Println("MQ is shutting down due to signal:", sig.String())
time.Sleep(time.Second)
fmt.Println("MQ is shut down smoothly")
}
func signalHandlerForMain(sig os.Signal) {
fmt.Println("MainProcess is shutting down due to signal:", sig.String())
}
func main() {
fmt.Println("Process start, pid:", os.Getpid())
gproc.AddSigHandlerShutdown(
signalHandlerForMQ,
signalHandlerForMain,
)
gproc.Listen()
}
go run能正确运行
gf run不能正确运行
Additional
No response
The text was updated successfully, but these errors were encountered:
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
@chaegumigf run has some differences compared to go run: It will monitor source code changes to implement automatic compilation and running. gf run will have a main process to manage this part of the logic, and the main process will not forward the received signal to the child process, but forcibly Kill it. The source code is here https://github.com/ gogf/gf/blob/183395f0a0f59c1680ce0e78638dd541e4e1c84e/cmd/gf/internal/cmd/cmd_run.go#L204. I briefly thought about it, and the improvement here may be relatively simple. If a signal is received, forward the signal to the child process, and execute the Wait method instead of Kill directly. If no signal is received, the original logic is followed.
Hello @chaegumi. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @chaegumi。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。
Description
go run能正确运行
gf run不能正确运行
Additional
No response
The text was updated successfully, but these errors were encountered: