📦 Detect Child process

Co-Authored-By: kiyon <kiyonlin@163.com>
pull/574/head
Fenny 2020-07-10 11:16:53 +02:00
parent 3bffdac364
commit 5df26c4647
1 changed files with 7 additions and 1 deletions

View File

@ -29,10 +29,16 @@ func init() { //nolint:gochecknoinits
flag.Usage = usage
}
// Child determines if the current environment is a child process
// This method can be usefull when Prefork is enabled.
func (app *App) Child() bool {
return utils.GetArgument(flagChild)
}
// prefork manages child processes to make use of the OS REUSEPORT or REUSEADDR feature
func (app *App) prefork(addr string, tlsconfig ...*tls.Config) (err error) {
// 👶 child process 👶
if utils.GetArgument(flagChild) {
if app.Child() {
// use 1 cpu core per child process
runtime.GOMAXPROCS(1)
var ln net.Listener