Relative dir

This commit is contained in:
Zorglube 2020-08-20 18:49:26 +02:00 committed by Bertrand Moreau
parent 77a707eea6
commit dc2965194c
1 changed files with 16 additions and 13 deletions

29
main.go
View File

@ -6,6 +6,7 @@ import (
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
"path/filepath"
"github.com/gorilla/sessions" "github.com/gorilla/sessions"
"github.com/nareix/joy4/format" "github.com/nareix/joy4/format"
@ -21,6 +22,7 @@ var (
stats = newStreamStats() stats = newStreamStats()
sAdminPass string sAdminPass string
confFile string confFile string
path string
) )
func setupSettings() error { func setupSettings() error {
@ -49,6 +51,7 @@ func setupSettings() error {
} }
func main() { func main() {
&path, err := filepath.Abs(filepath.Dir(os.Args[0]))
flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&addr, "l", "", "host:port of the HTTP server")
flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server")
flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream")
@ -132,20 +135,20 @@ func startRmtpServer() {
func startServer() { func startServer() {
// Chat websocket // Chat websocket
http.HandleFunc("/ws", wsHandler) http.HandleFunc(path+"/ws", wsHandler)
http.HandleFunc("/static/js/", wsStaticFiles) http.HandleFunc(path+"/static/js/", wsStaticFiles)
http.HandleFunc("/static/css/", wsStaticFiles) http.HandleFunc(path+"/static/css/", wsStaticFiles)
http.HandleFunc("/static/img/", wsImages) http.HandleFunc(path+"/static/img/", wsImages)
http.HandleFunc("/static/main.wasm", wsWasmFile) http.HandleFunc(path+"/static/main.wasm", wsWasmFile)
http.HandleFunc("/emotes/", wsEmotes) http.HandleFunc(path+"/emotes/", wsEmotes)
http.HandleFunc("/favicon.ico", wsStaticFiles) http.HandleFunc(path+"/favicon.ico", wsStaticFiles)
http.HandleFunc("/chat", handleIndexTemplate) http.HandleFunc(path+"/chat", handleIndexTemplate)
http.HandleFunc("/video", handleIndexTemplate) http.HandleFunc(path+"/video", handleIndexTemplate)
http.HandleFunc("/help", handleHelpTemplate) http.HandleFunc(path+"/help", handleHelpTemplate)
http.HandleFunc("/pin", handlePin) http.HandleFunc(path+"/pin", handlePin)
http.HandleFunc("/emotes", handleEmoteTemplate) http.HandleFunc(path+"/emotes", handleEmoteTemplate)
http.HandleFunc("/", handleDefault) http.HandleFunc(path+"/", handleDefault)
err := http.ListenAndServe(addr, nil) err := http.ListenAndServe(addr, nil)
if err != nil { if err != nil {