fixed path resolution
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ func init() {
|
||||
bro := webview.New(debug) /* create a browser instance */
|
||||
bro.SetSize(320, 720, webview.HintNone)
|
||||
defer bro.Destroy()
|
||||
bro.SetTitle("StreamGoose v0.0.1")
|
||||
bro.SetTitle("StreamGoose")
|
||||
bro.Navigate("http://" + target_addr)
|
||||
bro.Run()
|
||||
}
|
||||
|
||||
+3
-2
@@ -15,6 +15,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
/* global API root URL placeholder */
|
||||
@@ -124,11 +125,11 @@ func oc_process_message(rawmsg map[string]interface{}) {
|
||||
|
||||
/* entry point */
|
||||
func owncast_run(config map[string]interface{}) {
|
||||
token_path := "auth/oc-token.txt"
|
||||
token_path := filepath.Join(APP_ROOT_DIR, "auth", "oc-token.txt")
|
||||
token, err := ioutil.ReadFile(token_path)
|
||||
token_err_msg := "[owncast] No Owncast token file provided or it is empty. "
|
||||
token_err_msg += "Please generate a token in your Owncast admin panel "
|
||||
token_err_msg += "and paste it into the auth/oc-token.txt file!"
|
||||
token_err_msg += "and paste it into the " + token_path + " file!"
|
||||
if err != nil {
|
||||
log.Fatal(token_err_msg + "\nDetailed error: ", err)
|
||||
}
|
||||
|
||||
+14
-2
@@ -15,6 +15,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
/* main chat message structure */
|
||||
@@ -30,6 +31,7 @@ type ChatMessage struct {
|
||||
var global_msg_id uint64 = 0 /* track global message ID */
|
||||
var message_transport chan ChatMessage /* global message channel */
|
||||
var sse_transports []chan string /* SSE output channels */
|
||||
var APP_ROOT_DIR string /* global application root directory */
|
||||
|
||||
/* headless behaviour by default */
|
||||
var goose_start_gui = func(config map[string]interface{}) {
|
||||
@@ -130,7 +132,17 @@ func sseHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
/* entry point */
|
||||
func main() {
|
||||
config_path := "config.json"
|
||||
/* detect current executable directory and load the config from there */
|
||||
ex, err := os.Executable()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ex, err = filepath.EvalSymlinks(ex)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
APP_ROOT_DIR = filepath.Dir(ex)
|
||||
config_path := filepath.Join(APP_ROOT_DIR, "config.json")
|
||||
if len(os.Args) > 1 {
|
||||
config_path = os.Args[1]
|
||||
}
|
||||
@@ -158,7 +170,7 @@ func main() {
|
||||
/* serve the GET /sse */
|
||||
http.HandleFunc("/sse", sseHandler)
|
||||
/* serve the webroot directory */
|
||||
fs := http.FileServer(http.Dir("./webroot"))
|
||||
fs := http.FileServer(http.Dir(filepath.Join(APP_ROOT_DIR, "webroot")))
|
||||
http.Handle("/", fs)
|
||||
log.Println(fmt.Sprintf("Listening on %s\n", target_addr))
|
||||
err = http.ListenAndServe(target_addr, nil)
|
||||
|
||||
+3
-2
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
"net"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
@@ -143,11 +144,11 @@ func tw_process_message(rawmsg string) {
|
||||
|
||||
/* entry point */
|
||||
func twitch_run(config map[string]interface{}) {
|
||||
token_path := "auth/twitch-token.txt"
|
||||
token_path := filepath.Join(APP_ROOT_DIR, "auth", "twitch-token.txt")
|
||||
token, err := ioutil.ReadFile(token_path)
|
||||
token_err_msg := "[twitch] No Twitch token file provided or it is empty. "
|
||||
token_err_msg += "Please visit https://twitchapps.com/tmi/, generate a token there "
|
||||
token_err_msg += "and paste it into the auth/twitch-token.txt file!"
|
||||
token_err_msg += "and paste it into the " + token_path +" file!"
|
||||
if err != nil {
|
||||
log.Fatal(token_err_msg + "\nDetailed error: ", err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<title>StreamGoose v0.0.1</title>
|
||||
<title>StreamGoose</title>
|
||||
<link rel=stylesheet href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user