Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
# 实例
## 目录结构:
~~~
/opt/cache
/usr/local/goedge/
edge-admin/
configs/
api_admin.yaml
api_db.yaml
server.yaml
edge-api/
configs/api.yaml
configs/db.yaml
api-node/
configs/api_node.yaml
api-user/
configs/api_user.yaml
src/
/usr/bin/
edge-admin -> ...
edge-api -> ...
edge-node -> ...
edge-user -> ...
/usr/local/mysql
~~~
* 其中 `->` 表示软链接。
* `src/` 目录下放置zip格式的待安装压缩包
## 端口
* Admin7788
* API8001
* API HTTP8002
* User: 7799
* Server: 8080
## 数据库
数据库名称为 `edges`

View File

@@ -0,0 +1,16 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package instances
import "gopkg.in/yaml.v3"
type APIConfig struct {
RPCEndpoints []string `yaml:"rpc.endpoints,flow,omitempty" json:"rpc.endpoints"`
RPCDisableUpdate bool `yaml:"rpc.disableUpdate,omitempty" json:"rpc.disableUpdate"`
NodeId string `yaml:"nodeId" json:"nodeId"`
Secret string `yaml:"secret" json:"secret"`
}
func (this *APIConfig) AsYAML() ([]byte, error) {
return yaml.Marshal(this)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package instances_test
import (
"github.com/TeaOSLab/EdgeAPI/internal/instances"
"github.com/iwind/TeaGo/Tea"
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
)
var instance = instances.NewInstance(instances.Options{
Cacheable: true,
WorkDir: Tea.Root + "/standalone-instance",
SrcDir: Tea.Root + "/standalone-instance/src",
DB: struct {
Host string
Port int
Username string
Password string
Name string
}{
Host: "127.0.0.1",
Port: 3306,
Username: "root",
Password: "123456",
Name: "edges2",
},
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,
},
})
func TestInstanceSetupAll(t *testing.T) {
err := instance.SetupAll()
if err != nil {
t.Fatal(err)
}
}
func TestInstance_SetupDB(t *testing.T) {
err := instance.SetupDB()
if err != nil {
t.Fatal(err)
}
}
func TestInstance_SetupAdminNode(t *testing.T) {
err := instance.SetupAdminNode()
if err != nil {
t.Fatal(err)
}
}
func TestInstance_SetupAPINode(t *testing.T) {
err := instance.SetupAPINode()
if err != nil {
t.Fatal(err)
}
}
func TestInstance_SetupUserNode(t *testing.T) {
err := instance.SetupUserNode()
if err != nil {
t.Fatal(err)
}
}
func TestInstance_SetupNode(t *testing.T) {
err := instance.SetupNode()
if err != nil {
t.Fatal(err)
}
}
func TestInstance_Clean(t *testing.T) {
err := instance.Clean()
if err != nil {
t.Fatal(err)
}
}

View File

@@ -0,0 +1,32 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package instances
type Options struct {
IsTesting bool
Verbose bool
Cacheable bool
WorkDir string
SrcDir string
DB struct {
Host string
Port int
Username string
Password string
Name string
}
AdminNode struct {
Port int
}
APINode struct {
HTTPPort int
RestHTTPPort int
}
Node struct {
HTTPPort int
}
UserNode struct {
HTTPPort int
}
}