Documentation
¶
Overview ¶
Package autoreload restarts a process if its executable changes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCommand ¶
func WithCommand(cmd string) option
WithCommand defines the command executable that AutoReloader should watch. By default, this will be the currently running command.
func WithLogger ¶
func WithLogger(logger Logger) option
WithLogger defines the logger that the AutoReloader will use. By default, it will log using the built-in log package.
func WithMaxAttempts ¶
func WithMaxAttempts(maxAttempts int) option
WithMaxAttempts defines how many times the AutoReloader should attempt to reload the application. By default, this is 10.
func WithOnReload ¶
func WithOnReload(onReload onReloadFunc) option
WithOnReload defines a callback that is executed just prior to reloading the application. This is useful for gracefully shutting down your application.
Types ¶
type AutoReloader ¶
type AutoReloader struct {
// contains filtered or unexported fields
}
AutoReloader provides functionality for reloading an application.
func New ¶
func New(opts ...option) AutoReloader
New creates a new AutoReloader with the supplied options.
func (AutoReloader) Start ¶
func (ar AutoReloader) Start()
Start launches a goroutine that periodically checks if the modified time of the command has changed. If so, the binary is re-executed with the same arguments. This is a developer convenience and not intended to be started in a production environment.
func (AutoReloader) Stop ¶
func (ar AutoReloader) Stop()
Stop will stop the autoreloader from watching the executable and reloading it.