mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 15:10:49 +08:00
feat: handle polaris files on non docker env
This commit is contained in:
@@ -6,11 +6,12 @@ import (
|
||||
"os"
|
||||
"polaris/db"
|
||||
"polaris/log"
|
||||
"polaris/pkg/utils"
|
||||
"polaris/server"
|
||||
)
|
||||
|
||||
func main() {
|
||||
port := flag.Int("port", 8080, "port to listen on")
|
||||
port := flag.Int("port", 3322, "port to listen on")
|
||||
flag.Parse()
|
||||
|
||||
if os.Getenv("GIN_MODE") == "release" {
|
||||
@@ -22,6 +23,9 @@ func main() {
|
||||
if err != nil {
|
||||
log.Panicf("init db error: %v", err)
|
||||
}
|
||||
if !utils.IsRunningInDocker() {
|
||||
go utils.OpenURL(fmt.Sprintf("http://127.0.0.1:%d", *port))
|
||||
}
|
||||
|
||||
s := server.NewServer(dbClient)
|
||||
if _, err := s.Start(fmt.Sprintf(":%d", *port)); err != nil {
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func GetUserDataDir() string {
|
||||
return "./data"
|
||||
}
|
||||
if IsRunningInDocker() {
|
||||
return "./data"
|
||||
}
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
dir := filepath.Join(homeDir, ".polaris")
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
os.MkdirAll(dir, 0755)
|
||||
}
|
||||
|
||||
return dir
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user