nginxprocess

package
v3.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright (c) F5, Inc.

This source code is licensed under the Apache License, Version 2.0 license found in the LICENSE file in the root directory of this source tree.

Package nginxprocess contains utilities for working with OS-level NGINX processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotNginxErr

func IsNotNginxErr(err error) bool

IsNotNginxErr returns true if this error is due to the process not being an NGINX process.

func IsNotRunningErr

func IsNotRunningErr(err error) bool

IsNotRunningErr returns true if this error is due to the OS process no longer running.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option customizes how processes are gathered from the OS.

func WithStatus

func WithStatus(v bool) Option

WithStatus runs an additional lookup to load the process status.

type Process

type Process struct {
	// Created is when this process was created, precision varies by platform and is at best to the millisecond. On
	// linux there can be significant skew compared to [time.Now], ± 1s.
	Created time.Time
	Name    string
	Cmd     string
	Exe     string // path to the executable
	Status  string // process status, only present if this process was created using [WithStatus]
	PID     int32
	PPID    int32 // parent PID
}

Process contains a snapshot of read-only data about an OS-level NGINX process. Create using List or Find.

func Find

func Find(ctx context.Context, pid int32, opts ...Option) (*Process, error)

Find returns a single NGINX process by PID. Returns an error if the PID is no longer running or if it is not an NGINX process. Use with [IsProcessNotRunningErr] and IsNotNginxErr.

func List

func List(ctx context.Context, opts ...Option) (ret []*Process, err error)

List returns a slice of all NGINX processes. Returns a zero-length slice if no NGINX processes are found.

func ListWithProcesses

func ListWithProcesses(
	ctx context.Context,
	processes []*process.Process,
	opts ...Option,
) (ret []*Process, err error)

ListWithProcesses returns a slice of all NGINX processes. Returns a zero-length slice if no NGINX processes are found.

func (*Process) IsHealthy

func (p *Process) IsHealthy() bool

IsHealthy uses Status flags to judge process health. Only works on processes created using WithStatus.

func (*Process) IsMaster

func (p *Process) IsMaster() bool

IsMaster returns true if the process is a NGINX master process.

func (*Process) IsShuttingDown

func (p *Process) IsShuttingDown() bool

IsShuttingDown returns true if the process is shutting down. This can identify workers that are in the process of a graceful shutdown. See changing NGINX configuration for more details.

func (*Process) IsWorker

func (p *Process) IsWorker() bool

IsWorker returns true if the process is a NGINX worker process.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL