-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (32 loc) · 885 Bytes
/
main.go
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
package main
import (
"bytes"
"fmt"
"github.com/raidancampbell/pcabinet/conf"
"github.com/raidancampbell/pcabinet/tui"
"github.com/sirupsen/logrus"
"log"
"net/http"
_ "net/http/pprof"
"os"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
conf.Initialize()
buf := bytes.Buffer{}
logrus.SetOutput(&buf)
// no need to open HTTP listen ports by default. this is only useful for debugging pcabinet itself.
if os.Getenv("PCABINET_DEBUG") == "yes" {
go defaultWebServer()
}
model := tui.NewServiceSelector(conf.C.Services)
p := tea.NewProgram(model)
if err := p.Start(); err != nil {
log.Fatal(err)
}
fmt.Print(buf.String())
}
// defaultWebServer exists so that I can test it on itself. I don't wanna keep another long-running debug service around.
func defaultWebServer() {
logrus.Fatal(http.ListenAndServe("127.0.0.1:8080", http.DefaultServeMux))
}