services

package
v0.86.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package services runs a project's services: commands the user saved once (a container, a tunnel, a dev server) that lich starts on a PTY of their own and shows as up or down, outside the session list. A service lives as long as its project's tab: closing the tab stops it, reopening the project starts the ones saved to start with lich, and so does lich starting with the tab open. Closing the window leaves them all running; quitting lich stops them (Shutdown).

A service is not a shell. When its command exits, the service has stopped: nothing is respawned and no prompt is left behind, and what it printed last stays readable (Output) until it starts again.

Index

Constants

View Source
const ProjectCloseGrace = 10 * time.Second

ProjectCloseGrace is how long closing a project's tab waits for its services to stop on their own before killing them: Docker's own stop timeout, `docker compose up` being the service this is most often.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the services of every project and the process of each.

func New

func New(store Store, term *terminal.Service, emit func(name string, data any)) *Service

New returns the services of store, none of them running.

func (*Service) Boot

func (s *Service) Boot()

Boot starts the services saved to start with lich whose project has a tab open. One that fails to start is logged and shown failed; it does not hold up the others.

func (*Service) Delete

func (s *Service) Delete(_ context.Context, opts api.ServiceIDOptions) (api.None, error)

Delete removes a service that is not running. One that is running is refused rather than stopped on the way out: stopping can take a command a while, and deleting it under its feet would leave a process nothing lists.

func (*Service) ForceStop

func (s *Service) ForceStop(_ context.Context, opts api.ServiceIDOptions) (api.None, error)

ForceStop kills a service without waiting for it to agree.

func (*Service) List

func (s *Service) List(_ context.Context, _ api.None) ([]api.Service, error)

List is every service with its state, each project's in the order they were added.

func (*Service) LiveOutput added in v0.84.0

func (s *Service) LiveOutput(_ context.Context, opts api.ServiceIDOptions) ([]byte, error)

LiveOutput is what a running service has printed so far, read at the moment of the call: nil once it is not running, when Output has its last run.

func (*Service) Output

func (s *Service) Output(_ context.Context, opts api.ServiceIDOptions) ([]byte, error)

Output is what a service printed last, from the moment its last run exited: nil while it runs, its console being live on /ws then, or before it ever ran.

func (*Service) ProjectChanged

func (s *Service) ProjectChanged(name string, data any)

ProjectChanged follows the project list (store.SetProjectChanged): a project opened, or reopened, starts its services saved to start with lich, and one closed stops all of its services, off the caller's goroutine either way, since a stop can take grace to finish.

func (*Service) Restart

func (s *Service) Restart(_ context.Context, opts api.ServiceIDOptions) (api.None, error)

Restart stops a service and starts it again once it exited.

func (*Service) Reveal

func (s *Service) Reveal(id string)

Reveal asks the window to open service id's console.

func (*Service) Running

func (s *Service) Running() []api.Service

Running is every service whose process is up, stopping ones included.

func (*Service) Save

Save writes a service, a new one when opts.ID is empty. The name and the command are trimmed and both are required, and the name must be free in its project: the footer and the tray tell services apart by it. A running service keeps the command it was started with until its next start.

func (*Service) Shutdown

func (s *Service) Shutdown(grace time.Duration)

Shutdown stops every running service on lich's way out: asked first, then killed once grace is up, and waited for at most a few seconds more so no process outlives the backend that started it.

func (*Service) Start

func (s *Service) Start(_ context.Context, opts api.ServiceIDOptions) (api.None, error)

Start runs a service in its project's directory; see start.

func (*Service) StartAll

func (s *Service) StartAll(_ context.Context, opts api.ProjectIDOptions) (api.None, error)

StartAll starts every service of a project that is not running.

func (*Service) Stop

func (s *Service) Stop(_ context.Context, opts api.ServiceIDOptions) (api.None, error)

Stop asks a service to stop the way Ctrl+C at its console does; see stop.

func (*Service) StopAll

func (s *Service) StopAll(_ context.Context, opts api.ProjectIDOptions) (api.None, error)

StopAll stops every service of a project that is running.

func (*Service) StopRunning

func (s *Service) StopRunning()

StopRunning asks every running service, of every project, to stop.

type Store

type Store interface {
	Services() ([]api.ServiceConfig, error)
	SaveService(c api.ServiceConfig) error
	DeleteService(id string) error
	ProjectName(projectID string) string
	ProjectPath(projectID string) string
	ProjectOpen(projectID string) bool
}

Store is where services are saved, and the projects they run in.

Jump to

Keyboard shortcuts

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