Documentation
¶
Overview ¶
Package server assembles the roles a mainplane-server process runs. Today that is one role, harness.
Index ¶
Constants ¶
const (
Dir = "/var/lib/mainplane-server"
)
Variables ¶
var Conf = filepath.Join(Dir, "config.json")
Conf is the config the installed harness runs from.
Functions ¶
func Harness ¶
Harness runs the harness role on one loopback port, behind the user's own tunnel or a quick one, until ctx ends or the listener or the tunnel fails: workers open a WebSocket at /worker with a join secret, /id proves the harness key to anyone before they send one, connectors call every other route with an api key, every session that was open on start resumes. The pointer follows the tunnel's URL.
func Install ¶
Install makes this machine run the harness at every boot, from a copy of an expanded c at Conf, and returns its URL once it answers there. Dir is root's alone: the copy holds the keys.
func SetTunnel ¶ added in v0.2.0
SetTunnel makes the installed harness reached through t, or through a quick tunnel when t is nil, restarts it, and returns its URL once it answers there. Workers follow through the pointer.
func Uninstall ¶ added in v0.1.1
func Uninstall() error
Uninstall stops the harness and removes its service and binary. Dir stays: it holds the sessions.
Types ¶
type Config ¶
type Config struct {
Admin string `json:"admin"` // directory holding sessions, the auth table and the tunnel
HTTP string `json:"http"` // loopback address the tunnel carries connectors and workers to
Tunnel *Tunnel `json:"tunnel,omitempty"` // the user's own; none is a quick tunnel
Providers map[string]Provider `json:"providers"`
}
Config is the self-hosted config file. Provider values are expanded from the environment, so a key can be "$ANTHROPIC_API_KEY".
func Default ¶ added in v0.1.1
Default is the config install writes when given none: the tunnel carries workers and connectors to port 8080 on loopback, sessions live under Dir, and every provider whose key is set in this environment serves.