gaper

package
v0.0.0-...-f683405 Latest Latest
Warning

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

Go to latest
Published: May 30, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gaper implements a supervisor restarts a go project when it crashes or a watched file changes

Index

Constants

View Source
const OSWindows = "windows"

OSWindows is used to check if current OS is a Windows

Variables

View Source
var (
	NoRestartOnError   = "error"
	NoRestartOnSuccess = "success"
	NoRestartOnExit    = "exit"
)

No restart types

View Source
var DefaultBuildPath = "."

DefaultBuildPath is the default build and watched path

View Source
var DefaultExtensions = []string{"go", "yml"}

DefaultExtensions is the default watched extension

View Source
var DefaultPoolInterval = 500

DefaultPoolInterval is the time in ms used by the watcher to wait between scans

Functions

func Run

func Run(cfg *Config, chOSSiginal chan os.Signal) error

Run starts the whole gaper process watching for file changes or exit codes and restarting the program

Types

type Builder

type Builder interface {
	Build() error
	Binary() string
}

Builder is a interface for the build process

func NewBuilder

func NewBuilder(dir string, bin string, wd string, buildArgs []string) Builder

NewBuilder creates a new builder

type Config

type Config struct {
	BinName              string
	BuildPath            string
	BuildArgs            []string
	BuildArgsMerged      string
	ProgramArgs          []string
	ProgramArgsMerged    string
	WatchItems           []string
	IgnoreItems          []string
	PollInterval         int
	Extensions           []string
	NoRestartOn          string
	DisableDefaultIgnore bool
	WorkingDirectory     string
}

Config contains all settings supported by gaper

type Runner

type Runner interface {
	Run() (*exec.Cmd, error)
	Kill() error
	Errors() chan error
	Exited() bool
	IsRunning() bool
	ExitStatus(err error) int
}

Runner is a interface for the run process

func NewRunner

func NewRunner(wStdout io.Writer, wStderr io.Writer, bin string, args []string) Runner

NewRunner creates a new runner

type Watcher

type Watcher interface {
	Watch()
	Errors() chan error
	Events() chan string
}

Watcher is a interface for the watch process

func NewWatcher

func NewWatcher(cfg WatcherConfig) (Watcher, error)

NewWatcher creates a new watcher

type WatcherConfig

type WatcherConfig struct {
	DefaultIgnore bool
	PollInterval  int
	WatchItems    []string
	IgnoreItems   []string
	Extensions    []string
}

WatcherConfig defines the settings available for the watcher

Jump to

Keyboard shortcuts

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