mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 06:40:26 +08:00
实现单体实例安装工具
This commit is contained in:
2
cmd/standalone-instance-installer/.gitignore
vendored
Normal file
2
cmd/standalone-instance-installer/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
standalone-instance-installer*
|
||||
prepare.sh
|
||||
17
cmd/standalone-instance-installer/build.sh
Executable file
17
cmd/standalone-instance-installer/build.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
OS="${1}"
|
||||
ARCH="${2}"
|
||||
TAG="${3}"
|
||||
|
||||
if [ -z "$OS" ]; then
|
||||
echo "usage: build.sh OS ARCH"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$ARCH" ]; then
|
||||
echo "usage: build.sh OS ARCH"
|
||||
exit
|
||||
fi
|
||||
|
||||
env GOOS=linux GOARCH="${ARCH}" go build -tags="${TAG}" -trimpath -ldflags="-s -w" -o "standalone-instance-installer-${OS}-${ARCH}" main.go
|
||||
74
cmd/standalone-instance-installer/main.go
Normal file
74
cmd/standalone-instance-installer/main.go
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/instances"
|
||||
_ "github.com/iwind/TeaGo/bootstrap"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
dbPasswordData, err := os.ReadFile("/usr/local/mysql/generated-password.txt")
|
||||
if err != nil {
|
||||
fmt.Println("[ERROR]read mysql password failed: " + err.Error())
|
||||
return
|
||||
}
|
||||
var dbPassword = strings.TrimSpace(string(dbPasswordData))
|
||||
|
||||
var isTesting = lists.ContainsString(os.Args, "-test") || lists.ContainsString(os.Args, "--test")
|
||||
if isTesting {
|
||||
fmt.Println("testing mode ...")
|
||||
}
|
||||
|
||||
var instance = instances.NewInstance(instances.Options{
|
||||
IsTesting: isTesting,
|
||||
Verbose: lists.ContainsString(os.Args, "-v"),
|
||||
Cacheable: true,
|
||||
WorkDir: "",
|
||||
SrcDir: "/usr/local/goedge/src",
|
||||
DB: struct {
|
||||
Host string
|
||||
Port int
|
||||
Username string
|
||||
Password string
|
||||
Name string
|
||||
}{
|
||||
Host: "127.0.0.1",
|
||||
Port: 3306,
|
||||
Username: "root",
|
||||
Password: dbPassword,
|
||||
Name: "edges",
|
||||
},
|
||||
AdminNode: struct {
|
||||
Port int
|
||||
}{
|
||||
Port: 7788,
|
||||
},
|
||||
APINode: struct {
|
||||
HTTPPort int
|
||||
RestHTTPPort int
|
||||
}{
|
||||
HTTPPort: 8001,
|
||||
RestHTTPPort: 8002,
|
||||
},
|
||||
Node: struct{ HTTPPort int }{
|
||||
HTTPPort: 8080,
|
||||
},
|
||||
UserNode: struct {
|
||||
HTTPPort int
|
||||
}{
|
||||
HTTPPort: 7799,
|
||||
},
|
||||
})
|
||||
err = instance.SetupAll()
|
||||
if err != nil {
|
||||
fmt.Println("[ERROR]setup failed: " + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("ok")
|
||||
}
|
||||
Reference in New Issue
Block a user