|
@@ -12,6 +12,7 @@ import (
|
|
|
"os/exec"
|
|
"os/exec"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
+ "github.com/kardianos/osext"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var config map[string]interface{}
|
|
var config map[string]interface{}
|
|
@@ -65,7 +66,11 @@ func main() {
|
|
|
"stop_service": []interface{}{"demo"},
|
|
"stop_service": []interface{}{"demo"},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- configPath := "config.json"
|
|
|
|
|
|
|
+ folderPath, err := osext.ExecutableFolder()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ log.Fatal(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ configPath := folderPath + "/config.json"
|
|
|
if len(os.Args) > 1 {
|
|
if len(os.Args) > 1 {
|
|
|
configPath = os.Args[1]
|
|
configPath = os.Args[1]
|
|
|
}
|
|
}
|
|
@@ -122,5 +127,6 @@ func main() {
|
|
|
c.Data(http.StatusOK, "text/html", []byte(text))
|
|
c.Data(http.StatusOK, "text/html", []byte(text))
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- router.Run(fmt.Sprintf("%s:%.0f", config["host"], config["port"]))
|
|
|
|
|
|
|
+ router.Run(fmt.Sprintf("%s:%d", config["host"].(string), config["port"].(int)))
|
|
|
|
|
+
|
|
|
}
|
|
}
|