Skip to content

Commit

Permalink
Merge pull request #57 from OOrangeeee/online/deploy-debug
Browse files Browse the repository at this point in the history
feat(ci/cd):add (ci/cd)
  • Loading branch information
OOrangeeee authored Oct 14, 2024
2 parents c2d9c7f + 59d2ece commit 62477e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 76 deletions.
5 changes: 1 addition & 4 deletions internal/configs/middlewareConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -80,9 +79,7 @@ func InitMiddleware(e *echo.Echo, jwtSecret string) {
}
return false
},
SigningKey: func() []byte {
return []byte(viper.GetString("jwt.jwtSecret"))
}(),
SigningKey: []byte(jwtSecret),
TokenLookup: "header:Authorization:Bearer ",
ErrorHandler: func(c echo.Context, err error) error {
utils.Log.WithFields(logrus.Fields{
Expand Down
75 changes: 3 additions & 72 deletions test/test.go
Original file line number Diff line number Diff line change
@@ -1,77 +1,8 @@
package main

import (
"SEP/internal/utils"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
)
type testX struct {
s []byte
}

func main() {
source := "./uploads/1.png"
uuidTool := utils.UUIDTool{}
uuid := uuidTool.GenerateUUID()
ext := filepath.Ext(source)

// 创建新的文件名(UUID + 原扩展名)
newFileName := uuid + ext
newSource := filepath.Join(filepath.Dir(source), newFileName)

// 重命名文件
if err := os.Rename(source, newSource); err != nil {
println(0)
}

// 更新 source 为新的文件路径
source = newSource
localDir := "./temp/" + uuid
if err := os.MkdirAll(localDir, os.ModePerm); err != nil {
println("1")
}

sshPass := "sshpass -p 'WZ+34ybGhwC5' "
cmd := sshPass + fmt.Sprintf("ssh -p 27075 root@connect.yza1.seetacloud.com 'mkdir -p /services/images/%s'", uuid)
if err := exec.Command("bash", "-c", cmd).Run(); err != nil {
println("3")
println(err.Error())
}

scpCmd := sshPass + fmt.Sprintf("scp -P 27075 %s root@connect.yza1.seetacloud.com:/services/images/%s/", source, uuid)
if err := exec.Command("bash", "-c", scpCmd).Run(); err != nil {
println("4")
println(err.Error())
}

detectCmd := sshPass + fmt.Sprintf("ssh -p 27075 root@connect.yza1.seetacloud.com '/root/miniconda3/bin/python3.9 /sep/ai/ai/Polyp_detection/detect.py --weights /sep/ai/ai/Polyp_detection/weights/best.pt --source /services/images/%s/%s'", uuid, filepath.Base(source))
if err := exec.Command("bash", "-c", detectCmd).Run(); err != nil {
println("5")
println(err.Error())
println(detectCmd)
}

downloadCmd := sshPass + fmt.Sprintf("scp -rP 27075 root@connect.yza1.seetacloud.com:/sep/ai/ai/Polyp_detection/runs/detect %s/", localDir)
if err := exec.Command("bash", "-c", downloadCmd).Run(); err != nil {
println("6")
println(err.Error())
}
if err := os.Remove(source); err != nil {
println("2")
println(err.Error())
}
resultsDir := filepath.Join(localDir, "detect")
dirs, _ := ioutil.ReadDir(resultsDir)
for _, d := range dirs {
if d.IsDir() {
resultPath := filepath.Join(resultsDir, d.Name(), filepath.Base(source))
if _, err := os.Stat(resultPath); err == nil {
cleanupCmd := sshPass + fmt.Sprintf("ssh -p 27075 root@connect.yza1.seetacloud.com 'rm -rf /services/images/%s'", uuid)
if err := exec.Command("bash", "-c", cleanupCmd).Run(); err != nil {
println("7")
}
println(resultPath)
}
}
}
}

0 comments on commit 62477e5

Please sign in to comment.