Documentation
¶
Overview ¶
Package devtool runs the development servers so that several worktrees can run them at once without colliding on ports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Stdout io.Writer
Resolve func(context.Context) (Environment, error)
Ports PortAllocator
Processes ProcessManager
}
App implements the commands behind the mise start and docs tasks.
type Environment ¶
Environment locates the worktree a command runs in and the main worktree that every worktree of the repository shares.
func ResolveEnvironment ¶
func ResolveEnvironment(ctx context.Context) (Environment, error)
ResolveEnvironment describes the worktree containing the working directory.
func (Environment) CookieNamespace ¶
func (e Environment) CookieNamespace() string
CookieNamespace names this worktree's session cookie. The main worktree keeps the default cookie name. A linked worktree gets its directory name plus a hash of its path, so two worktrees with the same directory name in different places still differ.
func (Environment) PortLockRoot ¶
func (e Environment) PortLockRoot() string
PortLockRoot is where worktrees record the ports they hold. It lives in the main worktree so that every linked worktree sees the same locks.
type FilePortAllocator ¶
type FilePortAllocator struct {
LockRoot string
}
FilePortAllocator coordinates ports between worktrees with advisory locks. A port is only free if no other worktree holds its lock and nothing is listening on it. The lock closes the gap between choosing a port and the server binding it, and the kernel drops it if the process dies.
type OSProcesses ¶
type OSProcesses struct{}
OSProcesses runs development commands as child process groups.
func (*OSProcesses) Docs ¶
func (p *OSProcesses) Docs(ctx context.Context, env Environment, port int) error
Docs runs the documentation dev server.
func (*OSProcesses) Start ¶
func (p *OSProcesses) Start(ctx context.Context, env Environment, mode string, apiPort, webPort int) error
Start runs the servers for a start mode on the reserved ports. A zero port means the mode does not run that server.
type PortAllocator ¶
PortAllocator reserves the first available port at or above a preferred port.
type ProcessManager ¶
type ProcessManager interface {
Start(ctx context.Context, env Environment, mode string, apiPort, webPort int) error
Docs(ctx context.Context, env Environment, port int) error
}
ProcessManager runs the development servers.