aboutsummaryrefslogtreecommitdiffstats
path: root/lib/apiv1/make.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-10-11 09:36:05 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 15:57:04 +0100
commit8119c1641e88ee5020e380c08119f508c6e24222 (patch)
tree5b295fb9e210b9bf5cee52fdb4fcb16d6878fd27 /lib/apiv1/make.go
parenta3d2ca72d05d28b1ae5820787ff696dd75fd17cc (diff)
Add Server UUID and use it build CmdID.
Diffstat (limited to 'lib/apiv1/make.go')
-rw-r--r--lib/apiv1/make.go16
1 files changed, 10 insertions, 6 deletions
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,
})
}