Documentation ¶
Index ¶
- Constants
- Variables
- func KillOrphans()
- func NewMemoryFileSystem(path string, pattern *regexp.Regexp) (*memoryFileSystem, error)
- type AppServer
- type AppService
- func (app *AppService) BuildApp(c context.Context, force bool) (chk glob.Checksum, err error)
- func (app *AppService) Prepare(opt Options) error
- func (app *AppService) ShutdownApp(c context.Context, chk glob.Checksum) error
- func (app *AppService) Start(c context.Context, invaliate bool) (instance Instance, err error)
- func (app *AppService) String() string
- type BuildFS
- func (bfs BuildFS) AbortBuild()
- func (bfs BuildFS) Clean()
- func (bfs BuildFS) Folders() (r map[string]string)
- func (bfs BuildFS) LinkRun(buildDir string) error
- func (bfs BuildFS) PostBuild(chk glob.Checksum) error
- func (bfs BuildFS) PreBuild() error
- func (bfs BuildFS) ReadBuildId() (glob.Checksum, error)
- func (bfs BuildFS) RunBuild(chk glob.Checksum, cb func() error) error
- func (bfs BuildFS) UnlinkRun() error
- func (bfs BuildFS) WriteBuildId(id glob.Checksum, buildDir string) error
- type Command
- func (c *Command) Clone() *Command
- func (c *Command) Create(root string, ctx context.Context) *exec.Cmd
- func (c Command) IsZero() bool
- func (c Command) MarshalYAML() (any, error)
- func (c *Command) MergeEnv(m map[string]string)
- func (c Command) String() string
- func (c *Command) UnmarshalText(data []byte) error
- func (c *Command) UnmarshalYAML(node *yaml.Node) error
- type FileServer
- type FileService
- type FlaskApp
- type GluedCommand
- type GoApp
- type Instance
- type InstanceLB
- type InstanceProc
- type JsApp
- type NpmApp
- type Options
- type ProcMetrics
- type ProcTreeMetrics
- type ProcUsageMetrics
- type ProcessTree
- func (tree *ProcessTree) AddProcess(p *process.Process)
- func (tree *ProcessTree) AddProcessPid(pid int32)
- func (tree ProcessTree) IsParentRunning() bool
- func (tree ProcessTree) IsZero() bool
- func (tree ProcessTree) Kill()
- func (tree ProcessTree) Metrics() (metrics ProcTreeMetrics)
- func (tree ProcessTree) Refresh()
- type ProxyService
- func (px *ProxyService) GetLoadBalancer() *lb.LoadBalancer
- func (px *ProxyService) Prepare(opt Options) error
- func (px *ProxyService) ServeHTTP(w http.ResponseWriter, r *http.Request) vhttp.Result
- func (px *ProxyService) Start(c context.Context, invaliate bool) (Instance, error)
- func (px *ProxyService) Stop(context.Context)
- func (px *ProxyService) String() string
- func (px *ProxyService) UnmarshalInline(text string) error
- type PyApp
- type Service
Constants ¶
View Source
const ( BuilderRunDir = ".run" // -> links to .build-%s BuilderIdFile = ".buildid" // Contains the current build id BuilderBuildDir = ".build" // Used while building, renamed to .build-%s when done BuilderArchivePrefix = ".build-" // The build directory format )
Variables ¶
View Source
var DefaultBuildEnv = map[string]string{
"YARN_PRODUCTION": "1",
"PM3_BUILDING": "1",
}
View Source
var DefaultRunEnv = map[string]string{
"PM3": "1",
"DEBIAN_FRONTEND": "noninteractive",
"NODE_ENV": "production",
"npm_config_prod": "1",
"NODE_NO_WARNINGS": "1",
"FLASK_DEBUG": "0",
}
View Source
var Registry = variant.NewRegistry[service]()
View Source
var SubnetAllocator = sync.OnceValue(func() *subnet.Allocator { return subnet.NewAllocator(*config.ServiceSubnet, true) })
Functions ¶
func KillOrphans ¶
func KillOrphans()
Types ¶
type AppServer ¶
type AppServer struct { *AppService Checksum glob.Checksum Context context.Context LoadBalancer *lb.LoadBalancer // contains filtered or unexported fields }
func (*AppServer) GetLoadBalancer ¶
func (run *AppServer) GetLoadBalancer() *lb.LoadBalancer
func (*AppServer) GetProcessTrees ¶
func (run *AppServer) GetProcessTrees() (res []ProcessTree)
type AppService ¶
type AppService struct { Options Retry retry.Policy `yaml:"retry,omitempty"` // The retry policy. Monitor health.Monitor `yaml:"monitor,omitempty"` // The health monitor. LoadBalancerOpts lb.Options `yaml:"lb,omitempty"` // The load balancer. Root string `yaml:"root,omitempty"` // The root directory of the app. Run Command `yaml:"run,omitempty"` // The command to run the app. Build util.Some[Command] `yaml:"build,omitempty"` // The command to build the app. Shutdown util.Some[Command] `yaml:"shutdown,omitempty"` // The command to shutdown the app. Cluster string `yaml:"cluster,omitempty"` // The number of instances to run. Env map[string]string `yaml:"env,omitempty"` // The environment variables to set. EnvHost string `yaml:"env_host,omitempty"` // The environment variable for the host. EnvPort string `yaml:"env_port,omitempty"` // The environment variable for the port. EnvListen string `yaml:"env_listen,omitempty"` // The environment variable for the address. ReadyTimeout util.Duration `yaml:"ready_timeout,omitempty"` // The timeout for the app to become ready. StopTimeout util.Duration `yaml:"stop_timeout,omitempty"` // The timeout for the app to stop. NoBuildControl bool `yaml:"no_build_control,omitempty"` // If true, linking logic between .run and .build will be disabled. Background bool `yaml:"background,omitempty"` // If true, the app is not a HTTP server. LogFile string `yaml:"log,omitempty"` // The log file for stdout&stderr, default = app.log UnhealtyTimeout util.Duration `yaml:"unhealthy_timeout,omitempty"` // The timeout after which an unhealthy instance is killed. SlowStart bool `yaml:"slow_start,omitempty"` // If true, instances are started one by one. MaxMemory util.Size `yaml:"max_memory,omitempty"` // Maximum amount of memory the process is allowed to use, <= 0 means unlimited. AutoScale bool `yaml:"auto_scale,omitempty"` // If true, the app will be auto-scaled. UpscalePercent float64 `yaml:"upscale_percent,omitempty"` // The percentage of CPU usage to trigger upscale. DownscalePercent float64 `yaml:"downscale_percent,omitempty"` // The percentage of CPU usage to trigger downscale. // contains filtered or unexported fields }
func (*AppService) Prepare ¶
func (app *AppService) Prepare(opt Options) error
func (*AppService) ShutdownApp ¶
func (*AppService) String ¶
func (app *AppService) String() string
type BuildFS ¶
type BuildFS struct {
Root string
}
func (BuildFS) ReadBuildId ¶
Reads the build ID.
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
func CommandFromString ¶
func NewCommand ¶
func (Command) MarshalYAML ¶
func (*Command) UnmarshalText ¶
func (*Command) UnmarshalYAML ¶
type FileServer ¶
type FileServer struct { *FileService // contains filtered or unexported fields }
func (*FileServer) ServeHTTP ¶
func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) vhttp.Result
func (*FileServer) Stop ¶
func (fsrv *FileServer) Stop(context.Context)
type FileService ¶
type FileService struct { Options Path string `yaml:"path,omitempty"` // The path to serve NotFound string `yaml:"404,omitempty"` // Static file for 404 errors Dynamic bool `yaml:"dynamic,omitempty"` // If true, the fileserver will serve files directly from the filesystem instead of in-memory Immutable bool `yaml:"immutable,omitempty"` // If true, the fileserver will assume the files are immutable and set cache headers accordingly NoImmutableMatch bool `yaml:"no_immutable_match,omitempty"` // If true, the fileserver will not assume the files are immutable if the path contains /immutable/ IndexFile string `yaml:"index,omitempty"` // The index file to serve if the path is a directory Match *regexp.Regexp `yaml:"match,omitempty"` // The pattern to match }
func (*FileService) Prepare ¶
func (fsrv *FileService) Prepare(opt Options) error
func (*FileService) UnmarshalInline ¶
func (fsrv *FileService) UnmarshalInline(text string) error
type GluedCommand ¶
func (GluedCommand) Run ¶
func (cmd GluedCommand) Run() (err error)
func (GluedCommand) Start ¶
func (cmd GluedCommand) Start() (err error)
type GoApp ¶
type GoApp struct { AppService `yaml:",inline"` Main string `yaml:"main,omitempty"` }
type InstanceLB ¶
type InstanceLB interface {
GetLoadBalancer() *lb.LoadBalancer
}
type InstanceProc ¶
type InstanceProc interface {
GetProcessTrees() []ProcessTree
}
type JsApp ¶
type JsApp struct { AppService `yaml:",inline"` Index string `yaml:"index,omitempty"` }
type NpmApp ¶
type NpmApp struct { AppService `yaml:",inline"` StartScript string `yaml:"start_script,omitempty"` BuildScript string `yaml:"build_script,omitempty"` PackageManager string `yaml:"package_manager,omitempty"` NoInstall bool `yaml:"no_install,omitempty"` }
type ProcMetrics ¶
type ProcMetrics struct { PID int32 `json:"pid"` CreateTime time.Time `json:"create_time,omitempty"` Cmd string `json:"cmd,omitempty"` ProcUsageMetrics }
func GetProcMetrics ¶
func GetProcMetrics(p *process.Process) (metrics ProcMetrics)
func (*ProcMetrics) BriefCmd ¶
func (m *ProcMetrics) BriefCmd() string
type ProcTreeMetrics ¶
type ProcTreeMetrics struct { ProcMetrics Tree map[int32]ProcMetrics `json:"tree,omitempty"` }
type ProcUsageMetrics ¶
type ProcUsageMetrics struct { CPU float64 `json:"cpu,omitempty"` RSS uint64 `json:"rss,omitempty"` VMS uint64 `json:"vms,omitempty"` HWM uint64 `json:"hwm,omitempty"` Data uint64 `json:"data,omitempty"` Stack uint64 `json:"stack,omitempty"` Locked uint64 `json:"locked,omitempty"` Swap uint64 `json:"swap,omitempty"` IoRead uint64 `json:"io_read,omitempty"` IoWrite uint64 `json:"io_write,omitempty"` }
func (*ProcUsageMetrics) Combine ¶
func (u *ProcUsageMetrics) Combine(other ProcUsageMetrics)
func (*ProcUsageMetrics) Fill ¶
func (u *ProcUsageMetrics) Fill(proc *process.Process)
type ProcessTree ¶
func NewProcessTree ¶
func NewProcessTree(p *process.Process) (tree ProcessTree)
func (*ProcessTree) AddProcess ¶
func (tree *ProcessTree) AddProcess(p *process.Process)
func (*ProcessTree) AddProcessPid ¶
func (tree *ProcessTree) AddProcessPid(pid int32)
func (ProcessTree) IsParentRunning ¶
func (tree ProcessTree) IsParentRunning() bool
func (ProcessTree) IsZero ¶
func (tree ProcessTree) IsZero() bool
func (ProcessTree) Kill ¶
func (tree ProcessTree) Kill()
func (ProcessTree) Metrics ¶
func (tree ProcessTree) Metrics() (metrics ProcTreeMetrics)
func (ProcessTree) Refresh ¶
func (tree ProcessTree) Refresh()
type ProxyService ¶
type ProxyService struct { Options Monitor health.Monitor `yaml:"monitor,omitempty"` LoadBalancer lb.LoadBalancer `yaml:"lb,omitempty"` Upstreams util.Some[string] `yaml:"upstreams,omitempty"` }
func (*ProxyService) GetLoadBalancer ¶
func (px *ProxyService) GetLoadBalancer() *lb.LoadBalancer
func (*ProxyService) Prepare ¶
func (px *ProxyService) Prepare(opt Options) error
func (*ProxyService) ServeHTTP ¶
func (px *ProxyService) ServeHTTP(w http.ResponseWriter, r *http.Request) vhttp.Result
Implement service.Instance and service.InstanceLB
func (*ProxyService) Stop ¶
func (px *ProxyService) Stop(context.Context)
func (*ProxyService) UnmarshalInline ¶
func (px *ProxyService) UnmarshalInline(text string) error
type PyApp ¶
type PyApp struct { AppService `yaml:",inline"` Requirements string `yaml:"requirements,omitempty"` Main string `yaml:"main,omitempty"` // Main file to run }
Click to show internal directories.
Click to hide internal directories.