process

package module
v0.0.0-...-8b802d3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 8 Imported by: 8

README

go-processmanager

Updated version for 2024

  • Updated gopsutils to v4
    • bumps module target to golang 1.18+
  • Allows setting working directory
  • Breaking Change config.KillSignal is now an *int - avoids the need to parse at runtime. options.WithKillSignal will need to be updated.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLog

func NewLog(path string) *os.File

Create a new file for logging

func WithArgs

func WithArgs(s ...string) func(cfg *Config) error

func WithKillSignal

func WithKillSignal(i int) func(cfg *Config) error

WithKillSignal sets the given signal while attemping to stop. Defaults to 9

func WithName

func WithName(s string) func(cfg *Config) error

func WithSTDIN

func WithSTDIN(f *os.File) func(cfg *Config) error

func WithStateDir

func WithStateDir(s string) func(cfg *Config) error

func WithTemporaryStateDir

func WithTemporaryStateDir() func(cfg *Config) error

func WithWorkDir

func WithWorkDir(s string) func(cfg *Config) error

Types

type Config

type Config struct {
	Name        string
	Args        []string
	Combined    bool
	StateDir    string
	KillSignal  *int
	Environment []string
	Stdin       *os.File
	WorkDir     string
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Apply

func (cfg *Config) Apply(opts ...Option) error

Apply applies the given options to the config, returning the first error encountered (if any).

type Option

type Option func(cfg *Config) error

func WithEnvironment

func WithEnvironment(s ...string) Option

type Process

type Process struct {
	PID string
	// contains filtered or unexported fields
}

func New

func New(p ...Option) *Process

New builds up a new process with options

func (*Process) ExitCode

func (p *Process) ExitCode() (string, error)

ExitCode returns the exitcode associated with the process

func (*Process) IsAlive

func (p *Process) IsAlive() bool

IsAlive checks if the process is running or not

func (*Process) Run

func (p *Process) Run() error

Run starts the process and returns any error

func (*Process) StateDir

func (p *Process) StateDir() string

StateDir returns the process state directory

func (*Process) StderrPath

func (p *Process) StderrPath() string

StderrPath returns the file where the stderr of the process is appended to

func (*Process) StdoutPath

func (p *Process) StdoutPath() string

StdoutPath returns the file where the stdout is appended to

func (*Process) Stop

func (p *Process) Stop() error

Stop stops the running process by senging KillSignal to the PID annotated in the pidfile

Jump to

Keyboard shortcuts

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