Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/gf: run AddSigHandlerShutdown cannot work well #3752

Open
chaegumi opened this issue Sep 2, 2024 · 0 comments
Open

cmd/gf: run AddSigHandlerShutdown cannot work well #3752

chaegumi opened this issue Sep 2, 2024 · 0 comments

Comments

@chaegumi
Copy link

chaegumi commented Sep 2, 2024

Description

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不能正确运行
image

Additional

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant