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

design bfe program launch as service #847

Open
kwanhur opened this issue Sep 25, 2021 · 0 comments
Open

design bfe program launch as service #847

kwanhur opened this issue Sep 25, 2021 · 0 comments

Comments

@kwanhur
Copy link
Contributor

kwanhur commented Sep 25, 2021

bfe's entrance include many jobs to do, split them into different parts as below example. It'll take more scalabilities, like

  1. support callback when Init or Start
  2. register signal syscall.SIGHUP func as to do reload config
  3. close logger when Stop etc.

reference from go-svc

type bfe struct {
}

// Init do initialize
func (b *bfe) Init(env svc.Environment) error {
	flag.Parse()
	if *help {
		flag.PrintDefaults()
		return nil
	}

	return nil
}

// Start do start
func (b *bfe) Start() error {
	var err error
	var config bfe_conf.BfeConfig

	// start and serve
	if err = bfe_server.StartUp(config, version, *confRoot); err != nil {
		log.Logger.Error("main(): bfe_server.StartUp(): %s", err.Error())
		return err
	}

	return nil
}

// Stop do stop
func (b *bfe) Stop() error {
	return nil
}

func main() {
	b := &bfe{}
	if err := svc.Run(b, syscall.SIGINT, syscall.SIGTERM); err != nil {
		bfe_util.AbnormalExit()
	}
}
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

1 participant