Documentation ¶
Overview ¶
Package run starts and tracks running Encore applications.
Index ¶
- Constants
- type EventListener
- type Manager
- func (mgr *Manager) AddListener(ln EventListener)
- func (mgr *Manager) Check(ctx context.Context, appRoot, relwd string) error
- func (mgr *Manager) FindProc(procID string) *Proc
- func (mgr *Manager) FindRunByAppID(appID string) *Run
- func (mgr *Manager) ListRuns() []*Run
- func (mgr *Manager) Start(ctx context.Context, params StartParams) (run *Run, err error)
- func (mgr *Manager) Test(ctx context.Context, params TestParams) (err error)
- type Proc
- type Run
- type StartParams
- type TestParams
Constants ¶
const BasePort = 4060
BasePort is the default port Encore apps start listening on.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventListener ¶
type EventListener interface { // OnStart is called when a run starts. OnStart(r *Run) // OnReload is called when a run reloads. OnReload(r *Run) // OnStop is called when a run stops. OnStop(r *Run) // OnStdout is called when a run outputs something on stdout. OnStdout(r *Run, out []byte) // OnStderr is called when a run outputs something on stderr. OnStderr(r *Run, out []byte) }
EventListener is the interface for listening to events about running apps.
type Manager ¶
type Manager struct { RuntimePort int // port for Encore runtime DBProxyPort int // port for sqldb proxy DashPort int // port for dev dashboard Secret *secret.Manager // contains filtered or unexported fields }
Manager manages the set of running applications.
func (*Manager) AddListener ¶
func (mgr *Manager) AddListener(ln EventListener)
AddListener adds an event listener to mgr. It must be called before starting the first run.
func (*Manager) FindProc ¶
FindProc finds the proc with the given id. It reports nil if no such proc was found.
func (*Manager) FindRunByAppID ¶
FindRunByAppID finds the run with the given app id. It reports nil if no such run was found.
type Proc ¶
type Proc struct { ID string // unique process id Run *Run // the run the process belongs to Pid int // the OS process id Meta *meta.Data // app metadata snapshot Started time.Time // when the process started // contains filtered or unexported fields }
Proc represents a running Encore process.
type Run ¶
type Run struct { ID string // unique ID for this instance of the running app AppID string // unique identifier for the app AppSlug string // the optional app slug, if linked to encore.dev Root string // the filesystem path to the app root Port int // the port the app is listening on // contains filtered or unexported fields }
Run represents a running Encore application.
func (*Run) Done ¶
func (r *Run) Done() <-chan struct{}
Done returns a channel that is closed when the run is closed.
func (*Run) Proc ¶
Proc returns the current running process. It may have already exited. If the proc has not yet started it may return nil.
type StartParams ¶
type StartParams struct { // AppRoot is the application root. AppRoot string // AppID is the unique app id, as defined by the manifest. AppID string // WorkingDir is the working dir, for formatting // error messages with relative paths. WorkingDir string // DBClusterID is the database cluster id to connect to. DBClusterID string // Parse is the parse result for the initial run of the app. // If nil the app is parsed before starting. Parse *parser.Result // Watch enables watching for code changes for live reloading. Watch bool }
StartParams groups the parameters for the Run method.
type TestParams ¶
type TestParams struct { // AppRoot is the application root. AppRoot string // AppID is the unique app id, as defined by the manifest. AppID string // WorkingDir is the working dir, for formatting // error messages with relative paths. WorkingDir string // DBClusterID is the database cluster id to connect to. DBClusterID string // Parse is the parse result for the initial run of the app. // If nil the app is parsed before starting. Parse *parser.Result // Args are the arguments to pass to "go test". Args []string // Stdout and Stderr are where "go test" output should be written. Stdout, Stderr io.Writer }
TestParams groups the parameters for the Test method.