-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (29 loc) · 821 Bytes
/
Copy pathmain.go
File metadata and controls
35 lines (29 loc) · 821 Bytes
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
package main
import (
"flag"
"fmt"
"net/http"
"github.com/pbogut/hackdeck/pkg/handlers"
"github.com/pbogut/hackdeck/pkg/logger"
)
func main() {
port := flag.Int("port", 8191, "Port to listen on")
host := flag.String("host", "", "host to listen on")
printDebug := flag.Bool("debug", false, "Print debug messages")
flag.Parse()
addr := fmt.Sprintf("%s:%d", *host, *port)
if *printDebug {
logger.Init(logger.DEBUG)
} else {
logger.Init(logger.INFO)
}
handlers.Init()
http.HandleFunc("/", handlers.WsHandler)
http.HandleFunc("/ping", handlers.PingHandler)
http.HandleFunc("/reload", handlers.ReloadHandler)
// Start the HTTP server on port 8191
fmt.Printf("Starting server on %s\n", addr)
if err := http.ListenAndServe(addr, nil); err != nil {
logger.Fatal("Error starting server:", err)
}
}