Documentation
¶
Overview ¶
Package daemon is `moin daemon`: the process on a server that dials out to the hub and holds one WebSocket session to it.
Index ¶
- Constants
- Variables
- func FromAgent(ctx context.Context, dir string) error
- func Hello(dir string) protocol.Hello
- func LoadRules(file string) (*protocol.Rules, error)
- func RulesFile() string
- func Run(ctx context.Context, dir string, state State) error
- func StateDir() string
- func Uninstall(ctx context.Context, dir string, withApps bool, logf func(string, ...any)) ([]string, error)
- type State
Constants ¶
const DefaultRulesFile = "/etc/" + build.Name + "/rules"
DefaultRulesFile is where the owner of a server writes what the daemon may do there. MOIN_RULES overrides it. The daemon never writes this file.
const DefaultStateDir = "/var/lib/" + build.Name
DefaultStateDir is where a root daemon keeps its state. MOIN_STATE_DIR overrides it, for example when a daemon runs without root in development.
Variables ¶
var ErrNotRegistered = errors.New("daemon is not registered: run `" + build.Name + " daemon register --url <hub> --token <install token>`")
ErrNotRegistered means the daemon has no state yet and needs `moin daemon register`.
Functions ¶
func FromAgent ¶
FromAgent is `moin agent`, which only the old unit runs. It moves the server to the daemon and waits for systemd to stop it. When the move fails, it runs the daemon under the old unit, so the server stays online, and the next start tries again.
func Hello ¶
Hello describes this daemon and server, with its rules, the names of the secrets it keeps in dir and the env keys of its apps: never a value.
func LoadRules ¶
LoadRules reads the rules file. Without one, moin may do everything. A file with a mistake is an error, so a typo never allows what it meant to stop.
func Run ¶
Run holds the session until ctx ends and reconnects when it drops. A rejected daemon token ends Run, because retrying cannot fix it. Deploys keep running across reconnects.
func Uninstall ¶
func Uninstall(ctx context.Context, dir string, withApps bool, logf func(string, ...any)) ([]string, error)
Uninstall removes the daemon from this server: its systemd service, its binary and its state in dir. The apps keep running with their data, the proxy, the tunnel and the firewall, unless withApps: then it takes all of them down too, data included. It returns what stays on the server.
Types ¶
Source Files
¶
- access.go
- access_source.go
- addresses.go
- apps.go
- apps_compose.go
- apps_databases.go
- apps_deploy.go
- apps_env.go
- apps_run.go
- apps_unpack.go
- backup.go
- backup_postgres.go
- backup_sqlite.go
- bucket.go
- cleanup.go
- compose_file.go
- daemon.go
- data.go
- exec.go
- journal.go
- metrics.go
- migrate.go
- names.go
- postgres.go
- proxy.go
- railpack.go
- rename.go
- rules.go
- security.go
- uninstall.go
- update.go