Commit 1861eeb8 authored by ale's avatar ale
Browse files

Rename daemon -> agent

parent 75b23617
......@@ -27,19 +27,24 @@ service *foo* might have been running on, or where exactly on the
filesystem its data was stored; what we want is to be able to say
"restore the data for service *foo*".
# Overview
The tabacco system works using *agents*, running on all hosts you have
data on, and a centralized metadata database (*metadb*) that stores
information about each backup globally.
# Usage
The *tabacco* command has a number of sub-commands to invoke various
functions:
## daemon
## agent
The *daemon* sub-command starts the backup agent. This is meant to run
The *agent* sub-command starts the backup agent. This is meant to run
in background as a daemon (managed by init), and it will invoke backup
jobs periodically at their desired schedule.
The daemon will read its configuration from */etc/tabacco/config.yml*
The daemon will read its configuration from */etc/tabacco/agent.yml*
and its subdirectories by default, though this can be changed with the
`--config` option.
......@@ -206,8 +211,8 @@ command simply pipe its output to the backup tool, using the *pipe*
handler.
Contrary to the *file* handler seen before, the *pipe* handler can't
be used unless it is configured appropriately in a user-defined
handler.
be used unless it is configured appropriately, by creating a
user-defined handler.
Since it's impractical to access individual items within a single data
stream, pipe handlers operate on individual atoms: datasets containing
......
......@@ -10,15 +10,15 @@ import (
"git.autistici.org/ale/tabacco/util"
)
// Daemon holds a Manager and a Scheduler together, and runs periodic
// Agent holds a Manager and a Scheduler together, and runs periodic
// backup jobs for all known sources.
type Daemon struct {
type Agent struct {
mgr Manager
sched *jobs.Scheduler
}
// NewDaemon creates a new Daemon with the specified config.
func NewDaemon(ctx context.Context, configMgr *ConfigManager, ms MetadataStore) (*Daemon, error) {
// NewAgent creates a new Agent with the specified config.
func NewAgent(ctx context.Context, configMgr *ConfigManager, ms MetadataStore) (*Agent, error) {
mgr, err := NewManager(ctx, configMgr, ms)
if err != nil {
return nil, err
......@@ -37,19 +37,19 @@ func NewDaemon(ctx context.Context, configMgr *ConfigManager, ms MetadataStore)
}
})
return &Daemon{
return &Agent{
mgr: mgr,
sched: sched,
}, nil
}
// Close the Daemon and all associated resources.
func (d *Daemon) Close() {
// Close the Agent and all associated resources.
func (d *Agent) Close() {
d.mgr.Close() // nolint
d.sched.Stop()
}
func (d *Daemon) startHTTPServer(addr string) error {
func (d *Agent) startHTTPServer(addr string) error {
//http.Handle("/debug/jobs", d.mgr.StateManager)
http.Handle("/debug/sched", d.sched)
go http.ListenAndServe(addr, nil)
......
......@@ -13,26 +13,26 @@ import (
"github.com/google/subcommands"
)
type daemonCommand struct {
type agentCommand struct {
configPath string
httpAddr string
}
func (c *daemonCommand) Name() string { return "daemon" }
func (c *daemonCommand) Synopsis() string { return "start the backup daemon" }
func (c *daemonCommand) Usage() string {
return `daemon [<flags>]:
Start the backup daemon.
func (c *agentCommand) Name() string { return "agent" }
func (c *agentCommand) Synopsis() string { return "start the backup agent" }
func (c *agentCommand) Usage() string {
return `agent [<flags>]:
Start the backup agent.
`
}
func (c *daemonCommand) SetFlags(f *flag.FlagSet) {
f.StringVar(&c.configPath, "config", "/etc/tabacco/config.yml", "configuration `file`")
func (c *agentCommand) SetFlags(f *flag.FlagSet) {
f.StringVar(&c.configPath, "config", "/etc/tabacco/agent.yml", "configuration `file`")
f.StringVar(&c.httpAddr, "http-addr", ":5331", "listen `address` for the HTTP server exporting metrics and debugging")
}
func (c *daemonCommand) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
func (c *agentCommand) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
if f.NArg() > 0 {
log.Printf("error: too many arguments")
return subcommands.ExitUsageError
......@@ -71,7 +71,7 @@ func (c *daemonCommand) Execute(ctx context.Context, f *flag.FlagSet, args ...in
return subcommands.ExitFailure
}
d, err := tabacco.NewDaemon(ctx, configMgr, store)
d, err := tabacco.NewAgent(ctx, configMgr, store)
if err != nil {
log.Printf("error: %v", err)
return subcommands.ExitFailure
......@@ -79,13 +79,13 @@ func (c *daemonCommand) Execute(ctx context.Context, f *flag.FlagSet, args ...in
defer d.Close() // nolint
// Wait for the outmost Context to terminate (presumably due to SIGTERM).
log.Printf("backup manager started")
log.Printf("backup agent started")
<-ctx.Done()
log.Printf("backup manager stopped")
log.Printf("backup agent stopped")
return subcommands.ExitSuccess
}
func init() {
subcommands.Register(&withSignalHandlers{&daemonCommand{}}, "")
subcommands.Register(&withSignalHandlers{&agentCommand{}}, "")
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment