Home / Function/ watchMaster() — fiber Function Reference

watchMaster() — fiber Function Reference

Architecture documentation for the watchMaster() function in prefork.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  1d38d225_f9eb_da1d_8937_6e20eea89b24["watchMaster()"]
  8f3667ad_bf3e_1448_af92_703572fb17e0["prefork.go"]
  1d38d225_f9eb_da1d_8937_6e20eea89b24 -->|defined in| 8f3667ad_bf3e_1448_af92_703572fb17e0
  style 1d38d225_f9eb_da1d_8937_6e20eea89b24 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

prefork.go lines 157–175

func watchMaster() {
	if runtime.GOOS == windowsOS {
		// finds parent process,
		// and waits for it to exit
		p, err := os.FindProcess(os.Getppid())
		if err == nil {
			_, _ = p.Wait() //nolint:errcheck // It is fine to ignore the error here
		}
		os.Exit(1) //nolint:revive // Calling os.Exit is fine here in the prefork
	}
	// if it is equal to 1 (init process ID),
	// it indicates that the master process has exited
	const watchInterval = 500 * time.Millisecond
	for range time.NewTicker(watchInterval).C {
		if os.Getppid() == 1 {
			os.Exit(1) //nolint:revive // Calling os.Exit is fine here in the prefork
		}
	}
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does watchMaster() do?
watchMaster() is a function in the fiber codebase, defined in prefork.go.
Where is watchMaster() defined?
watchMaster() is defined in prefork.go at line 157.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free