Skip to content

Commit

Permalink
chore(Config): addedn configurable webserver host and port
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesuaheli committed Dec 26, 2024
1 parent f32521b commit a5d6684
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ event:
#animated: true

webserver:
# The host on which the webserver is bound to
#host:
# The port on which the webserver listens
port: 8080
# The path to the favicon for the webserver
favicon: webserver/favicon.png

twitch:
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ func main() {
}

log.Println("Starting webserver...")
addr := ":8080"
webserver.Run(addr, webChan)
webserver.Run(webChan)

// Wait to end the bot
log.Println("Press Ctrl+C to exit")
Expand Down
4 changes: 3 additions & 1 deletion webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"cake4everybot/webserver/twitch"
"cake4everybot/webserver/youtube"
logger "log"
"net"
"net/http"
"time"

Expand All @@ -42,9 +43,10 @@ func initHTTP() http.Handler {
}

// Run starts the webserver at the given address
func Run(addr string, webChan chan struct{}) {
func Run(webChan chan struct{}) {
handler := initHTTP()

var addr string = net.JoinHostPort(viper.GetString("webserver.host"), viper.GetString("webserver.port"))
var err error

go func() {
Expand Down

0 comments on commit a5d6684

Please sign in to comment.