F symlink rollback

This commit is contained in:
zhenorzz 2021-10-12 17:36:16 +08:00
parent 33112ef351
commit b7fb187671
3 changed files with 8 additions and 5 deletions

View File

@ -249,10 +249,10 @@ func (Deploy) Rebuild(gp *core.Goploy) *core.Response {
var sshOutbuf, sshErrbuf bytes.Buffer
session.Stdout = &sshOutbuf
session.Stderr = &sshErrbuf
symlinkPath := path.Join(project.SymlinkPath, project.Name, reqData.Token)
destDir := path.Join(project.SymlinkPath, project.LastPublishToken)
// check if the path is exist or not
if err := session.Run("cd " + symlinkPath); err != nil {
if err := session.Run("cd " + destDir); err != nil {
core.Log(core.ERROR, "projectID:"+strconv.FormatInt(project.ID, 10)+" check symlink path err: "+err.Error()+", detail: "+sshErrbuf.String())
ch <- false
return
@ -264,7 +264,10 @@ func (Deploy) Rebuild(gp *core.Goploy) *core.Response {
ch <- false
return
}
afterDeployCommands := []string{"ln -sfn " + symlinkPath + " " + project.Path}
relativeDestDir := strings.Replace(destDir, path.Dir(project.Path), ".", 1)
var afterDeployCommands []string
afterDeployCommands = append(afterDeployCommands, "ln -sfn "+relativeDestDir+" "+project.Path)
afterDeployCommands = append(afterDeployCommands, "touch -m "+destDir)
if len(project.AfterDeployScript) != 0 {
scriptMode := "bash"
if len(project.AfterDeployScriptMode) != 0 {

View File

@ -218,7 +218,7 @@ func install() {
envContent := "# when you edit its value, you need to restart\n"
envContent += "DB_TYPE=mysql\n"
envContent += fmt.Sprintf(
"DB_CONN=%s%s@tcp(%s:%s)/goploy?charset=utf8mb4,utf8\n",
"DB_CONN=%s%s@(%s:%s)/goploy?charset=utf8mb4,utf8\n",
mysqlUser,
mysqlPassword,
mysqlHost,

View File

@ -132,7 +132,7 @@
/>
</el-radio>
<el-button type="danger" plain @click="rebuild(item)">
rebuild
rollback
</el-button>
</el-row>
</el-row>