web

package
v0.2.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 24 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 web runs website hosting accounts on a node: one Linux user per account, its own PHP-FPM master as a systemd unit (cgroup limits, sandbox), Caddy site blocks imported by the node's Caddyfile, MariaDB databases and a crontab. Everything the panel sends is validated here before it reaches a config file or a command line.

Index

Constants

This section is empty.

Variables

View Source
var WordPressURL = "https://wordpress.org/latest.tar.gz"

WordPressURL is the official release (tests point it elsewhere).

Functions

func Caddy

func Caddy(s proto.WebsiteSpec) string

Caddy renders the account's site blocks. Suspended accounts answer 503.

func Crontab

func Crontab(s proto.WebsiteSpec) string

Crontab renders the account's crontab ("%" is special in cron and is escaped).

func DatabaseName

func DatabaseName(user, name string) (string, error)

DatabaseName is the full name of an account database: <username>_<suffix>.

func FPMConfig

func FPMConfig(s proto.WebsiteSpec) string

FPMConfig renders the account's php-fpm.conf (the master runs as the account user).

func Unit

func Unit(s proto.WebsiteSpec, fpmBinary string) string

Unit renders the systemd unit: the PHP-FPM master as the account user, in its own cgroup with limits, and sandboxed so it sees only its home directory.

func ValidDomain

func ValidDomain(d string) bool

ValidDomain accepts lowercase host names (no wildcards, no IPs, at most 253 characters).

func Validate

func Validate(s proto.WebsiteSpec) error

Validate checks a spec completely; nothing reaches the system before it passes.

Types

type Manager

type Manager struct {
	DataDir   string // specs live in <DataDir>/websites
	CaddyDir  string // site blocks, imported by the Caddyfile
	CaddyFile string
	Logger    *slog.Logger
	// Exec runs a command (replaced in tests).
	Exec func(ctx context.Context, stdin []byte, name string, args ...string) ([]byte, error)
	// contains filtered or unexported fields
}

Manager runs the websites of this node.

func New

func New(dataDir string, logger *slog.Logger) *Manager

New creates the manager with the default system paths.

func (*Manager) App

App installs WordPress or deploys a Git repository into one of the account's domains.

func (*Manager) Apply

func (m *Manager) Apply(ctx context.Context, s proto.WebsiteSpec) error

Apply creates or updates a website; it is idempotent.

func (*Manager) Backup

Backup creates, restores, deletes or lists archives in ~/backups. An archive holds sites/ and databases/<name>.sql. Archives live in the user's home, so on restore they are untrusted: they are unpacked as the account user, and SQL is imported through a temporary database user that can only touch that one database.

func (*Manager) Capabilities

func (m *Manager) Capabilities() proto.WebCapabilities

Capabilities reports the web stack installed on this node.

func (*Manager) CheckQuota

func (m *Manager) CheckQuota(id string, n int64) error

CheckQuota refuses writes of n more bytes once the account is at its disk limit.

func (*Manager) DB

DB manages the account's databases. Each database has a user of the same name that may only use that database (at most 20 connections).

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, id string) error

Delete removes a website: its PHP unit, site blocks, cron, databases, files and user.

func (*Manager) DiskLoop

func (m *Manager) DiskLoop(ctx context.Context)

DiskLoop measures every website's disk use every 5 minutes.

func (*Manager) IDs

func (m *Manager) IDs() []string

IDs lists the websites on this node.

func (*Manager) Load

func (m *Manager) Load() error

Load reads the websites known to this node.

func (*Manager) Lookup

func (m *Manager) Lookup(id string) (dir string, uid int, ok bool)

Lookup returns a website's home directory and owner (file manager and SFTP).

func (*Manager) Status

func (m *Manager) Status(ctx context.Context, id string) (proto.WebsiteStatus, error)

Status reports whether PHP runs and how much disk the account uses.

Jump to

Keyboard shortcuts

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