mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-19 13:27:53 +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:
parent
5df26c4647
commit
0fd57d134d
@ -29,16 +29,15 @@ func init() { //nolint:gochecknoinits
|
|||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
}
|
}
|
||||||
|
|
||||||
// Child determines if the current environment is a child process
|
// IsChild determines if the current process is a result of Prefork
|
||||||
// This method can be usefull when Prefork is enabled.
|
func (app *App) IsChild() bool {
|
||||||
func (app *App) Child() bool {
|
|
||||||
return utils.GetArgument(flagChild)
|
return utils.GetArgument(flagChild)
|
||||||
}
|
}
|
||||||
|
|
||||||
// prefork manages child processes to make use of the OS REUSEPORT or REUSEADDR feature
|
// 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) {
|
func (app *App) prefork(addr string, tlsconfig ...*tls.Config) (err error) {
|
||||||
// 👶 child process 👶
|
// 👶 child process 👶
|
||||||
if app.Child() {
|
if app.IsChild() {
|
||||||
// use 1 cpu core per child process
|
// use 1 cpu core per child process
|
||||||
runtime.GOMAXPROCS(1)
|
runtime.GOMAXPROCS(1)
|
||||||
var ln net.Listener
|
var ln net.Listener
|
||||||
|
Loading…
x
Reference in New Issue
Block a user