watchdog

package
v0.0.0-...-5152f1c Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindProcessByName

func FindProcessByName(name string) (int, bool, error)

FindProcessByName find the process name specified by name and return the PID of that process. If the process is not found, the bool is false. NOTE: This require container with shared process namespace (if run as side-car).

func NewFileWatcherWatchdog

func NewFileWatcherWatchdog() *cobra.Command

NewFileWatcherWatchdog return the file watcher watchdog command. This command should be used as a side-car to a container which will react to file changes in the main container and terminate the main container process in case a change is observed. TODO: If the main container start before the watchdog side-car container (image pull) there might be a case

		 the watchdog won't react to a changed file (simply because it is not running yet). In that case the main process
      will not be reloaded. However, the operator image should be pulled on master node and therefore chances to hit this
      case are minimal.

func ProcessExists

func ProcessExists(pid int) (bool, error)

ProcessExists checks if the process specified by a PID exists in the /proc filesystem. Error is returned when the stat on the /proc dir fail (permission issue).

Types

type FileWatcherOptions

type FileWatcherOptions struct {
	// ProcessName is the name of the process to look for in /proc if non-empty,
	// indentifying the process to send SIGTERM to.
	ProcessName string
	// PidFile contains the pid of the process to send SIGTERM to. Can be empty.
	PidFile string

	// Files lists all files we want to monitor for changes
	Files      []string
	KubeConfig string

	// Namespace to report events to
	Namespace string

	// Interval specifies how aggressive we want to be in file checks
	Interval time.Duration

	// Time to give the process to terminate gracefully
	TerminationGracePeriod time.Duration

	// ReadyFile is touched when the watched files have been initially read
	ReadyFile string
	// contains filtered or unexported fields
}

func NewFileWatcherOptions

func NewFileWatcherOptions() *FileWatcherOptions

func (*FileWatcherOptions) AddFlags

func (o *FileWatcherOptions) AddFlags(fs *pflag.FlagSet)

func (*FileWatcherOptions) Complete

func (o *FileWatcherOptions) Complete() error

func (*FileWatcherOptions) Run

Run the main watchdog loop.

func (*FileWatcherOptions) Validate

func (o *FileWatcherOptions) Validate() error

Jump to

Keyboard shortcuts

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