51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
// Command archied is the archie orchestrator daemon
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/samcharles93/archie-core/internal/app/archied"
|
|
"github.com/samcharles93/archie-core/internal/app/archieplaybooks"
|
|
"github.com/samcharles93/archie-core/internal/app/prbench"
|
|
)
|
|
|
|
const commandUsage = "usage: archied [flags] # run the daemon; archied -h lists the flags\n" +
|
|
"subcommands: setup, update, release, status, prbench, playbooks"
|
|
|
|
func main() {
|
|
os.Exit(run(os.Args[1:]))
|
|
}
|
|
|
|
func run(args []string) int {
|
|
// The setup generator is dispatched before the daemon's flags are
|
|
// parsed: it writes a first-run config.toml and must not touch the
|
|
// store, NATS, or the running daemon's configuration.
|
|
if archied.IsSetupArgs(args) {
|
|
return archied.RunSetup(args[1:], os.Stdin, os.Stdout, os.Stderr)
|
|
}
|
|
if len(args) > 0 {
|
|
switch args[0] {
|
|
case "update":
|
|
return archied.RunUpdate(args[1:], os.Stdout, os.Stderr)
|
|
case "release":
|
|
return archied.RunRelease(args[1:], os.Stdout, os.Stderr)
|
|
case "status":
|
|
return archied.RunStatus(args[1:], os.Stdout, os.Stderr)
|
|
case "prbench":
|
|
return prbench.Main(args[1:], os.Stdout, os.Stderr)
|
|
case "playbooks":
|
|
return archieplaybooks.Run(args[1:], os.Stderr)
|
|
}
|
|
// A word that is not a subcommand is refused rather than ignored: a
|
|
// stale `archied update-topology` would otherwise start a second
|
|
// daemon under the running one's feet.
|
|
if !strings.HasPrefix(args[0], "-") {
|
|
fmt.Fprintf(os.Stderr, "archied: unknown command %q\n%s\n", args[0], commandUsage)
|
|
return 2
|
|
}
|
|
}
|
|
return archied.Run()
|
|
}
|