Documentation
¶
Overview ¶
Package selfhost installs the workspace platform on a customer's own server (ADR-0021): Ubuntu 24.04+ with Docker and systemd. PostgreSQL runs as a container with a volume; the platform is the devopus-server binary run by systemd as a system user, with its settings in an environment file only root reads. Every action goes through a Host, so a dry run prints them and tests check them.
Index ¶
- Constants
- func Backup(ctx context.Context, h Host, now time.Time) (string, error)
- func Download(ctx context.Context, base string) ([]byte, error)
- func Health(ctx context.Context, url string) error
- func Install(ctx context.Context, h Host, o Options) error
- func ReadEnv(h Host) (map[string]string, error)
- func ReleaseURL(version string) string
- func Replace(binary string, data []byte) error
- func Restore(ctx context.Context, h Host, file string) error
- func Uninstall(ctx context.Context, h Host, purge bool) error
- func Unit(binary string) string
- func UpgradeUnits(binary string) (path, service string)
- type DryRun
- func (d DryRun) MkdirAll(p string, perm os.FileMode) error
- func (d DryRun) ReadFile(string) ([]byte, error)
- func (d DryRun) Remove(p string) error
- func (d DryRun) Run(_ context.Context, name string, args ...string) (string, error)
- func (d DryRun) RunInput(ctx context.Context, _ io.Reader, name string, args ...string) (string, error)
- func (d DryRun) WriteFile(p string, data []byte, perm os.FileMode) error
- type Host
- type Options
- type Status
- type System
- func (System) MkdirAll(p string, perm os.FileMode) error
- func (System) ReadFile(p string) ([]byte, error)
- func (System) Remove(p string) error
- func (System) Run(ctx context.Context, name string, args ...string) (string, error)
- func (System) RunInput(ctx context.Context, in io.Reader, name string, args ...string) (string, error)
- func (System) WriteFile(p string, d []byte, perm os.FileMode) error
Constants ¶
const ( EnvFile = "/etc/devopus/server.env" PGEnvFile = "/etc/devopus/postgres.env" UnitFile = "/etc/systemd/system/devopus-server.service" Service = "devopus-server" // The upgrade unit applies a release the owner asked for in the web (package // update): the path unit watches the request, the service runs as root. UpgradePathFile = "/etc/systemd/system/devopus-server-upgrade.path" UpgradeServiceFile = "/etc/systemd/system/devopus-server-upgrade.service" UpgradePath = "devopus-server-upgrade.path" UpgradeDir = "/var/lib/devopus-server/upgrade" DataDir = "/var/lib/devopus-server" BackupDir = "/var/backups/devopus-server" User = "devopus" PGContainer = "devopus-server-postgres" PGVolume = "devopus-server-pgdata" PGImage = "postgres:17-alpine" PGPort = "5439" Database = "devopus" )
Where things go on the server.
const DefaultProxyListen = "127.0.0.1:7481"
DefaultProxyListen is where the platform listens behind a proxy of the host.
Variables ¶
This section is empty.
Functions ¶
func Download ¶
Download fetches the devopus-server binary of a release for this machine, checked against the release's checksums.
func Install ¶
Install sets the server up, or updates an installed one: the database password and data stay.
func ReleaseURL ¶
ReleaseURL is where releases are: $DEVOPUS_BASE_URL, as for install.sh.
func Replace ¶
Replace puts a new binary in place of the running one with a rename: the running server keeps its file until it restarts.
func UpgradeUnits ¶ added in v0.2.0
UpgradeUnits are the units that apply a requested release as root.
Types ¶
type DryRun ¶
DryRun prints what would be done and does nothing; reads find nothing.
type Host ¶
type Host interface {
Run(ctx context.Context, name string, args ...string) (string, error)
// RunInput runs a command with stdin (a restore feeds the dump in).
RunInput(ctx context.Context, in io.Reader, name string, args ...string) (string, error)
ReadFile(path string) ([]byte, error)
WriteFile(path string, data []byte, perm os.FileMode) error
Remove(path string) error
MkdirAll(path string, perm os.FileMode) error
}
Host runs commands and writes files on the server.
type Options ¶
type Options struct {
// Domain the server answers on, with HTTPS from Let's Encrypt; its DNS must point
// here and ports 80 and 443 be open.
Domain string
// Workspace and Owner make the platform's one workspace at its first start: its
// name and its owner's email. A later install keeps them unless given again.
Workspace, Owner string
// Mail sends invites: "log" or smtp://user:password@host:587, from MailFrom.
Mail, MailFrom string
// Proxy puts the platform behind a proxy of the host's own (nginx, Caddy…) that
// holds the domain's certificate: the platform serves plain HTTP on Listen
// (127.0.0.1:7481 by default) and trusts X-Forwarded-For.
Proxy bool
Listen string
// Binary is the devopus-server binary systemd runs.
Binary string
Log io.Writer
}
Options of an install.
type Status ¶
type Status struct {
Installed bool
Domain string
// URL is where the server answers on this host: its domain, or behind a proxy of
// the host its own address.
URL string
Service string // active, inactive, failed…
Database string // running, stopped, missing
}
Status describes the installed server.