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

There will be two processes #238

Open
mycode65678 opened this issue Jan 24, 2019 · 2 comments
Open

There will be two processes #238

mycode65678 opened this issue Jan 24, 2019 · 2 comments

Comments

@mycode65678
Copy link

When two processes occur, the modified code will not take effect. You need to manually end the process and run it again.

devdeMacBook-Pro:src dev$ ps -ax|grep cash-caiji
34036 ttys001    0:00.00 grep cash-caiji
33983 ttys002    0:24.77 /Volumes/data/go/bin/cash-caiji
34005 ttys002    0:24.56 /Volumes/data/go/bin/cash-caiji
@mycode65678
Copy link
Author

I found that I used github.com/gocraft/work and there will be multiple processes. Note that this code will not be.

func main() {
	gin.SetMode(gin.ReleaseMode)
	go web.Start()
	// Note that the following code will not appear multiple processes, just run the queue listener
	queue := tasks.Queue{}
	go queue.Start()

	select {}
}


@erikdubbelboer
Copy link

My guess is that package starts separate processes as workers. And since you aren't calling queue.Stop() when your program exists it doesn't kill those worker processes. Try something the following code:

func main() {
	gin.SetMode(gin.ReleaseMode)
	go web.Start()
	// Note that the following code will not appear multiple processes, just run the queue listener
	queue := tasks.Queue{}
	go queue.Start()

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, os.Kill)
	<-c

	queue.Stop()
}

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

No branches or pull requests

2 participants