-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
56 lines (51 loc) · 1.41 KB
/
Copy pathmain.go
File metadata and controls
56 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
// stackd — boot bring-up + watchdog for the `stacks` program.
// It does NOT talk to Docker for lifecycle itself; it DRIVES `stacks`
// (stacks up <stack> [service] <repair|fix|recreate>) and only uses docker
// read-only to check what's running. One file per concern.
import (
"fmt"
"os"
)
func main() {
if len(os.Args) < 2 {
usage()
os.Exit(1)
}
args := os.Args[2:]
switch os.Args[1] {
case "boot":
cmdBoot(args) // boot.go
case "watch":
cmdWatch(args) // watch.go
case "status":
cmdStatus(args) // status.go
case "install":
cmdInstall(args) // install.go
case "uninstall":
cmdUninstall(args) // install.go
case "config":
if len(args) > 0 && args[0] == "init" {
if err := writeDefaultConfig(); err != nil {
fmt.Println("error:", err)
}
}
fmt.Println(configPath())
case "version", "-v", "--version":
fmt.Println("stackd v0.1")
default:
usage()
os.Exit(1)
}
}
func usage() {
fmt.Println(`stackd — keeps your 24/7 stacks running, on top of the stacks program.
usage: stackd <command> [--dry-run]
boot start the configured 24/7 services (one-shot; used at boot)
watch run the watchdog loop (keeps the 24/7 set alive)
status show config + which 24/7 services are up
install write systemd units + default config (checks for stacks)
uninstall remove the systemd units
config init write a default config file you can edit
version`)
}