发出中断信号后 调用的都是BaseStarter中的Stop函数
来源:8-8 golang中如何优雅的退出进程-notify hook starter编码实战
wlison
2020-08-27
3回答
-
枫荇
2020-09-08
是的,逻辑是监听到信号后,执行starter的Stop,由于golang的结构体包含原因,默认是使用”Starter
“接口,所以应该没问题的,注册的是哪个结构体就会调用哪个结构体的stop,如果包含了BaseStarter并且未覆盖,则会执行BaseStarter的stop.这个同学可以使用时需要注意。
```
[2020-09-08.18:00:38.135805] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:base.PropsStarter
[2020-09-08.18:00:38.135969] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:base.DbxDatabaseStarter
[2020-09-08.18:00:38.136071] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:base.ValidatorStarter
[2020-09-08.18:00:38.136182] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:base.GoRPCStarter
[2020-09-08.18:00:38.136277] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:gorpc.GoRpcApiStarter
[2020-09-08.18:00:38.136411] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:jobs.RefundExpiredJobStarter
[2020-09-08.18:00:38.136510] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:infra.WebApiStarter
[2020-09-08.18:00:38.136602] INFO imooc.com/resk/infra.(*HookStarter).Stop(infra/hook.go:43): stopping starter:base.IrisServerStarter
```
00 -
wlison
提问者
2020-08-27
应该是组合的问题 但是老师这个确实需要更改一下
00 -
wlison
提问者
2020-08-27
go 14.1
00
相似问题