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

fix issue: Windows Platform did not handle process signal #3154

Merged
merged 2 commits into from
Nov 14, 2023

Conversation

zhangyuyu
Copy link
Contributor

Add handleProcessSignal logic for windows platform which will AddSigHandlerShutdown and Listen process signal.

@hailaz
Copy link
Member

hailaz commented Nov 14, 2023

#3153

@gqcn gqcn merged commit 84ed660 into gogf:master Nov 14, 2023
20 checks passed
@chaegumi
Copy link

chaegumi commented Sep 2, 2024

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

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

Successfully merging this pull request may close these issues.

4 participants