diff --git a/handler/cid.go b/handler/cid.go index 4f64aa5..56f0655 100644 --- a/handler/cid.go +++ b/handler/cid.go @@ -68,13 +68,23 @@ func RunCID(c *gin.Context) { //脚本内容,不同用户的持续集成、部署目录不同 scriptContent := ` echo "start" -TARGET_DIR=` + proto.CID_BASE_DIR + username.(string) + `/workspace/` + name + ` +TARGET_DIR=` + proto.CID_BASE_DIR + username.(string) + `/workspace/` + name + ` if [ ! -d $TARGET_DIR ]; then git clone ` + cid.Url + ` - cd $TARGET_DIR -else - cd $TARGET_DIR - git pull + if [ $? -ne 0 ]; then + echo "Failed to clone repository." + exit 1 + fi +fi +cd "$TARGET_DIR" +if [ $? -ne 0 ]; then + echo "Failed to change directory to $TARGET_DIR." + exit 1 +fi +git pull +if [ $? -ne 0 ]; then + echo "Failed to pull repository." + exit 1 fi ` + cid.Script + ` echo "end"` @@ -208,13 +218,23 @@ func CIDCallback(c *gin.Context) { user := dao.FindUserByUserID(res.Auth_id) scriptContent := ` echo "start" -TARGET_DIR=` + proto.CID_BASE_DIR + user.Name + `workspace/` + name + ` +TARGET_DIR=` + proto.CID_BASE_DIR + user.Name + `/workspace/` + name + ` if [ ! -d $TARGET_DIR ]; then git clone ` + res.Url + ` - cd $TARGET_DIR -else - cd $TARGET_DIR - git pull + if [ $? -ne 0 ]; then + echo "Failed to clone repository." + exit 1 + fi +fi +cd "$TARGET_DIR" +if [ $? -ne 0 ]; then + echo "Failed to change directory to $TARGET_DIR." + exit 1 +fi +git pull +if [ $? -ne 0 ]; then + echo "Failed to pull repository." + exit 1 fi ` + res.Script + ` echo "end"` diff --git a/handler/im.go b/handler/im.go index 7340624..d4552f9 100644 --- a/handler/im.go +++ b/handler/im.go @@ -144,6 +144,7 @@ func SRMessage(c *gin.Context) { } defer ws.Close() res := worker.GetRedis(redis_key + "_connection") + worker.SetRedisWithExpire("user_"+id.(string)+"_status", "1", time.Second*5) if res == "" { return }