Relative running

This commit is contained in:
Zorglube 2020-08-20 19:06:34 +02:00
parent 9d16f2407e
commit 462363c6f6

39
main.go
View File

@ -22,7 +22,7 @@ var (
stats = newStreamStats() stats = newStreamStats()
sAdminPass string sAdminPass string
confFile string confFile string
path string runPath string
) )
func setupSettings() error { func setupSettings() error {
@ -51,11 +51,12 @@ func setupSettings() error {
} }
func main() { func main() {
&path, err := filepath.Abs(filepath.Dir(os.Args[0])) ex, er := os.Executable()
if err != nil { if er != nil {
log.Fatal(err) panic(er)
} }
fmt.Println(path) runPath := filepath.Dir(ex)
fmt.Println(runPath)
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")
@ -140,20 +141,20 @@ func startRmtpServer() {
func startServer() { func startServer() {
// Chat websocket // Chat websocket
http.HandleFunc(path+"/ws", wsHandler) http.HandleFunc(runPath+"/ws", wsHandler)
http.HandleFunc(path+"/static/js/", wsStaticFiles) http.HandleFunc(runPath+"/static/js/", wsStaticFiles)
http.HandleFunc(path+"/static/css/", wsStaticFiles) http.HandleFunc(runPath+"/static/css/", wsStaticFiles)
http.HandleFunc(path+"/static/img/", wsImages) http.HandleFunc(runPath+"/static/img/", wsImages)
http.HandleFunc(path+"/static/main.wasm", wsWasmFile) http.HandleFunc(runPath+"/static/main.wasm", wsWasmFile)
http.HandleFunc(path+"/emotes/", wsEmotes) http.HandleFunc(runPath+"/emotes/", wsEmotes)
http.HandleFunc(path+"/favicon.ico", wsStaticFiles) http.HandleFunc(runPath+"/favicon.ico", wsStaticFiles)
http.HandleFunc(path+"/chat", handleIndexTemplate) http.HandleFunc(runPath+"/chat", handleIndexTemplate)
http.HandleFunc(path+"/video", handleIndexTemplate) http.HandleFunc(runPath+"/video", handleIndexTemplate)
http.HandleFunc(path+"/help", handleHelpTemplate) http.HandleFunc(runPath+"/help", handleHelpTemplate)
http.HandleFunc(path+"/pin", handlePin) http.HandleFunc(runPath+"/pin", handlePin)
http.HandleFunc(path+"/emotes", handleEmoteTemplate) http.HandleFunc(runPath+"/emotes", handleEmoteTemplate)
http.HandleFunc(path+"/", handleDefault) http.HandleFunc(runPath+"/", handleDefault)
err := http.ListenAndServe(addr, nil) err := http.ListenAndServe(addr, nil)
if err != nil { if err != nil {