1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-14 13:46:23 +00:00

📦 Detect Child process

Co-Authored-By: kiyon <kiyonlin@163.com>
Co-Authored-By: Nathaniel Peiffer <nathaniel@peiffer.com.au>
This commit is contained in:
Fenny 2020-07-10 11:43:08 +02:00
parent 5df26c4647
commit 0fd57d134d

View File

@ -29,16 +29,15 @@ 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 {
// IsChild determines if the current process is a result of Prefork
func (app *App) IsChild() 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 app.Child() {
if app.IsChild() {
// use 1 cpu core per child process
runtime.GOMAXPROCS(1)
var ln net.Listener