diff options
Diffstat (limited to 'lib/apiv1')
-rw-r--r-- | lib/apiv1/events.go | 3 | ||||
-rw-r--r-- | lib/apiv1/exec.go | 11 | ||||
-rw-r--r-- | lib/apiv1/make.go | 16 |
3 files changed, 20 insertions, 10 deletions
diff --git a/lib/apiv1/events.go b/lib/apiv1/events.go index da8298c..b87486f 100644 --- a/lib/apiv1/events.go +++ b/lib/apiv1/events.go @@ -112,6 +112,9 @@ func (s *APIService) eventsRegister(c *gin.Context) { Folder: *cfg, } + s.log.Debugf("Event emit %s - ID=%s, Status=%s IsInSync=%v", EventEventType+evType, cfg.ID, + cfg.Status, cfg.IsInSync) + if err := (*so).Emit(EventEventType+evType, msg); err != nil { s.log.Errorf("WS Emit Folder StateChanged event : %v", err) } diff --git a/lib/apiv1/exec.go b/lib/apiv1/exec.go index fd0f8bb..0167196 100644 --- a/lib/apiv1/exec.go +++ b/lib/apiv1/exec.go @@ -19,7 +19,8 @@ type ( // ExecArgs JSON parameters of /exec command ExecArgs struct { ID string `json:"id" binding:"required"` - SdkID string `json:"sdkid"` // sdk ID to use for setting env + SdkID string `json:"sdkID"` // sdk ID to use for setting env + CmdID string `json:"cmdID"` // command unique ID Cmd string `json:"cmd" binding:"required"` Args []string `json:"args"` Env []string `json:"env"` @@ -168,11 +169,13 @@ func (s *APIService) execCmd(c *gin.Context) { } // Unique ID for each commands - cmdID := strconv.Itoa(execCommandID) - execCommandID++ + if args.CmdID == "" { + args.CmdID = s.cfg.ServerUID[:18] + "_" + strconv.Itoa(execCommandID) + execCommandID++ + } // Create new execution over WS context - execWS := eows.New(strings.Join(cmd, " "), cmdArgs, sop, sess.ID, cmdID) + execWS := eows.New(strings.Join(cmd, " "), cmdArgs, sop, sess.ID, args.CmdID) execWS.Log = s.log // Append client project dir to environment diff --git a/lib/apiv1/make.go b/lib/apiv1/make.go index cf76476..223d4bf 100644 --- a/lib/apiv1/make.go +++ b/lib/apiv1/make.go @@ -15,7 +15,8 @@ import ( // MakeArgs is the parameters (json format) of /make command type MakeArgs struct { ID string `json:"id"` - SdkID string `json:"sdkid"` // sdk ID to use for setting env + SdkID string `json:"sdkID"` // sdk ID to use for setting env + CmdID string `json:"cmdID"` // command unique ID Args []string `json:"args"` // args to pass to make command Env []string `json:"env"` RPath string `json:"rpath"` // relative path into project @@ -171,8 +172,11 @@ func (s *APIService) buildMake(c *gin.Context) { } } - cmdID := strconv.Itoa(makeCommandID) - makeCommandID++ + // Unique ID for each commands + if args.CmdID == "" { + args.CmdID = s.cfg.ServerUID[:18] + "_" + strconv.Itoa(makeCommandID) + makeCommandID++ + } cmd := []string{} // Retrieve env command regarding Sdk ID @@ -186,14 +190,14 @@ func (s *APIService) buildMake(c *gin.Context) { cmd = append(cmd, args.Args...) } - s.log.Debugf("Execute [Cmd ID %d]: %v", cmdID, cmd) + s.log.Debugf("Execute [Cmd ID %d]: %v", args.CmdID, cmd) data := make(map[string]interface{}) data["ID"] = prj.ID data["RootPath"] = prj.RootPath data["ExitImmediate"] = args.ExitImmediate - err := common.ExecPipeWs(cmd, args.Env, sop, sess.ID, cmdID, execTmo, s.log, oCB, eCB, &data) + err := common.ExecPipeWs(cmd, args.Env, sop, sess.ID, args.CmdID, execTmo, s.log, oCB, eCB, &data) if err != nil { common.APIError(c, err.Error()) return @@ -202,6 +206,6 @@ func (s *APIService) buildMake(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "status": "OK", - "cmdID": cmdID, + "cmdID": args.CmdID, }) } |