mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-12 19:33:41 +00:00
feat: direct call download api by cgo dart
This commit is contained in:
1 parent
467ada5500
commit
91dfd78b77
71 files changed
+6936
-1883
No files matched your search
+9
-3
@@ -3,14 +3,20 @@ package main
|
||||
import (
|
||||
"github.com/GopeedLab/gopeed/cmd"
|
||||
"github.com/GopeedLab/gopeed/pkg/api/model"
|
||||
"github.com/GopeedLab/gopeed/pkg/base"
|
||||
)
|
||||
|
||||
// only for local development
|
||||
func main() {
|
||||
cfg := &model.StartConfig{
|
||||
Network: "tcp",
|
||||
Address: "127.0.0.1:9999",
|
||||
Storage: model.StorageBolt,
|
||||
Storage: model.StorageBolt,
|
||||
DownloadConfig: &base.DownloaderStoreConfig{
|
||||
Http: &base.DownloaderHttpConfig{
|
||||
Enable: true,
|
||||
Host: "127.0.0.1",
|
||||
Port: 9999,
|
||||
},
|
||||
},
|
||||
WebEnable: true,
|
||||
}
|
||||
cmd.Start(cfg)
|
||||
|
||||
+9
-6
@@ -21,6 +21,7 @@ func Start(cfg *model.StartConfig) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
downloadCfgResult := instance.GetConfig()
|
||||
if downloadCfgResult.HasError() {
|
||||
panic(downloadCfgResult.Msg)
|
||||
@@ -52,13 +53,15 @@ func Start(cfg *model.StartConfig) {
|
||||
}
|
||||
}
|
||||
}
|
||||
startResult := instance.Start()
|
||||
if startResult.HasError() {
|
||||
panic(startResult.Msg)
|
||||
}
|
||||
fmt.Printf("Server start success on http://%s:%s\n", startResult.Data.Host, startResult.Data.Port)
|
||||
|
||||
watchExit(instance)
|
||||
|
||||
result, start, err := api.ListenHttp(cfg.DownloadConfig.Http, instance)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("Server start success on http://%s:%d\n", result.Host, result.Port)
|
||||
start()
|
||||
}
|
||||
|
||||
func watchExit(instance *api.Instance) {
|
||||
@@ -67,7 +70,7 @@ func watchExit(instance *api.Instance) {
|
||||
go func() {
|
||||
sig := <-sigs
|
||||
fmt.Printf("Server is shutting down due to signal: %s\n", sig)
|
||||
instance.Stop()
|
||||
instance.Close()
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
+2
-2
@@ -35,8 +35,8 @@ func parse() *args {
|
||||
|
||||
// args priority: config file > cli args
|
||||
cfgArgs := loadConfig(*cliArgs.configPath)
|
||||
if cfgArgs.Address == nil {
|
||||
cfgArgs.Address = cliArgs.Address
|
||||
if cfgArgs.Host == nil {
|
||||
cfgArgs.Host = cliArgs.Host
|
||||
}
|
||||
if cfgArgs.Port == nil {
|
||||
cfgArgs.Port = cliArgs.Port
|
||||
|
||||
@@ -46,6 +46,7 @@ func main() {
|
||||
args.DownloadConfig = &base.DownloaderStoreConfig{}
|
||||
}
|
||||
args.DownloadConfig.Http = &base.DownloaderHttpConfig{
|
||||
Enable: true,
|
||||
Host: *args.Host,
|
||||
Port: *args.Port,
|
||||
ApiToken: *args.ApiToken,
|
||||
|
||||
Reference in new issue
Block a user