process

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyRunning  = errors.New("supervisor is running")
	ErrNotRunning      = errors.New("supervisor is not running")
	ErrExitedWithCode  = errors.New("exited with error code")
	ErrExitedWithError = errors.New("exited with error")
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string
	Args []string
}

func (Command) Exec

func (c Command) Exec() *exec.Cmd

func (Command) ExecContext

func (c Command) ExecContext(ctx context.Context) *exec.Cmd

func (Command) MarshalText

func (c Command) MarshalText() ([]byte, error)

func (Command) String

func (c Command) String() string

func (*Command) UnmarshalText

func (c *Command) UnmarshalText(p []byte) error

type MuxWriter

type MuxWriter interface {
	Writer(string) io.Writer
	RegisterName(string) (int, lipgloss.Style)
}
Example
package main

import (
	"fmt"
	"os"

	"github.com/maidata/procfly/internal/process"
)

func main() {
	pwf := process.NewMuxWriter(os.Stdout)

	prw1 := pwf.Writer("a")
	fmt.Fprint(prw1, "bc\ndef")
	fmt.Fprintln(prw1, "ghi")

	prw2 := pwf.Writer("ab")
	fmt.Fprintln(prw2, "jkl\nmno")

	fmt.Fprintln(prw1, "pqr")

}
Output:

a | bc
a | def
a | ghi
ab | jkl
ab | mno
a  | pqr

func NewMuxWriter

func NewMuxWriter(dst io.Writer) MuxWriter

type OnChange

type OnChange struct {
	Run Command `yaml:"run"`
}

type Supervisor

type Supervisor interface {
	RegisterInit(string, Command)
	RegisterProcess(string, Command)
	RegisterReload(string, Command)
	// Run all of the supervisor's registered
	// commands
	Run() error
	// Run all of the supervisor's registered
	// reload scripts
	Reload() error
	// Log a message with the given prefix, using
	// the supervisor's multiplexed (prefixed) writer
	Log(name, message string)
	Logf(name, message string, args ...any)
}

func NewSupervisor

func NewSupervisor(ctx context.Context) Supervisor

Jump to

Keyboard shortcuts

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