proc

package
v0.0.0-...-fb34658 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PetsCommand

type PetsCommand struct {
	Proc PetsProc
	Cmd  *exec.Cmd
}

type PetsProc

type PetsProc struct {
	// A name to show to humans
	DisplayName string `json:",omitempty"`

	// The process ID of a running process.
	Pid int `json:",omitempty"`

	// When the process started
	StartTime time.Time

	// The hostname that the process is listening on (e.g., 'localhost')
	Hostname string `json:",omitempty"`

	// The port that the process is listening on (e.g., '8080')
	Port int `json:",omitempty"`

	// The name+tier of the service that this process exposes
	ServiceName service.Name `json:",omitempty"`
	ServiceTier service.Tier `json:",omitempty"`
}

Process state that we expect to be written to disk and queried.

func (PetsProc) Host

func (p PetsProc) Host() string

func (PetsProc) ServiceKey

func (p PetsProc) ServiceKey() service.Key

func (PetsProc) TimeSince

func (p PetsProc) TimeSince() time.Duration

func (PetsProc) WithExposedHost

func (p PetsProc) WithExposedHost(hostname string, port int) PetsProc

Creates a new PetsProc that we know is listening on the given host and port.

Calling this method automatically creates a copy because it's a struct method rather than a pointer method.

func (PetsProc) WithServiceKey

func (p PetsProc) WithServiceKey(key service.Key) PetsProc

Creates a new PetsProc that matches a service key.

Calling this method automatically creates a copy because it's a struct method rather than a pointer method.

type ProcFS

type ProcFS struct {
	// contains filtered or unexported fields
}

Saves state about the currently running processes to the filesystem.

func NewProcFS

func NewProcFS() (ProcFS, error)

func NewProcFSWithDir

func NewProcFSWithDir(wmDir *dirs.WindmillDir) (ProcFS, error)

func (ProcFS) AddProc

func (f ProcFS) AddProc(proc PetsProc) error

Add a proc to the JSON file

func (ProcFS) KillAllForTesting

func (f ProcFS) KillAllForTesting() error

Kill all the procs in the JSON file with a sigkill This is really only suitable for testing. 'pets down' uses a more graceful sigint with output.

func (ProcFS) ModifyProc

func (f ProcFS) ModifyProc(proc PetsProc) error

Replace a proc in the JSON file matching the given proc's PID

func (ProcFS) OpenFreshLogFile

func (f ProcFS) OpenFreshLogFile(key service.Key) (*os.File, error)

Open a log file for writing. Truncate any existing contents of the file.

func (ProcFS) ProcsFromFS

func (f ProcFS) ProcsFromFS() ([]PetsProc, error)

Read all the procs from the JSON file

func (ProcFS) ReadLogFile

func (f ProcFS) ReadLogFile(key service.Key) (string, error)

Returns the empty string if the log file doesn't exist.

func (ProcFS) RemoveAllProcs

func (f ProcFS) RemoveAllProcs() error

Remove all procs from the JSON file

func (ProcFS) RemoveDeadProcs

func (f ProcFS) RemoveDeadProcs() error

Remove all dead proc from the JSON file

func (ProcFS) RemoveProc

func (f ProcFS) RemoveProc(proc PetsProc) error

Remove a proc from the JSON file. If the process has already died, that's ok, it's not an error.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(fs ProcFS) Runner

func (Runner) Run

func (r Runner) Run(args []string, cwd string) error

Run a command, waiting until it exits.

args: The command to run. cwd: The current working directory.

func (Runner) RunWithIO

func (r Runner) RunWithIO(args []string, cwd string, stdout, stderr io.Writer) error

Run a command, waiting until it exits, forwarding all stdout/stderr to the given streams.

func (Runner) StartWithIO

func (r Runner) StartWithIO(args []string, cwd string, stdout, stderr io.Writer) (PetsCommand, error)

Starts a command, waiting until it exits, forwarding all stdout/stderr to the given streams.

func (Runner) StartWithStdLogs

func (r Runner) StartWithStdLogs(args []string, cwd string, key service.Key) (PetsCommand, error)

Jump to

Keyboard shortcuts

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