Merge branch 'V3.7' of https://github.com/goodrain/rainbond into V3.7

This commit is contained in:
zhoujunhao 2018-07-27 14:59:23 +08:00
commit 25fa958a84
4 changed files with 30 additions and 11 deletions

View File

@ -1,3 +1,15 @@
# Compile the project
```
# if you have golang environment
make build
# if you have docker environment
make image
# if you what build one component
make build WHAT=api
make image WHAT=api
```
# How to contribute
Read [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/) before contribute.

View File

@ -393,6 +393,7 @@ func (i *SourceCodeBuildItem) buildCode() error {
"-sid", i.ServiceID,
"-r", i.Runtime,
"-g", i.Lang,
"-st", i.CodeSouceInfo.ServerType,
"--name", buildName}
if len(i.BuildEnvs) != 0 {
buildEnvStr := ""
@ -408,7 +409,7 @@ func (i *SourceCodeBuildItem) buildCode() error {
cmd = append(cmd, "-e")
cmd = append(cmd, buildEnvStr)
}
logrus.Debugf("source code build cmd:%s", cmd)
if err := ShowExec("perl", cmd, i.Logger); err != nil {
i.Logger.Error("编译代码包失败", map[string]string{"step": "build-code", "status": "failure"})
logrus.Error("build perl error,", err.Error())

View File

@ -110,7 +110,7 @@ func RegisterWorker(name string, fun func([]byte, *exectorManager) (TaskWorker,
//share-image share app with image
func (e *exectorManager) AddTask(task *pb.TaskMessage) error {
e.wg.Add(1)
TaskNum += 1
TaskNum++
switch task.TaskType {
case "build_from_image":
e.buildFromImage(task.TaskBody)
@ -157,7 +157,7 @@ func (e *exectorManager) exec(workerName string, in []byte) error {
}
}()
if err := worker.Run(time.Minute * 10); err != nil {
ErrorNum += 1
ErrorNum++
worker.ErrorCallBack(err)
}
}()
@ -188,10 +188,9 @@ func (e *exectorManager) buildFromImage(in []byte) {
if n < 1 {
i.Logger.Error("从镜像构建应用任务执行失败,开始重试", map[string]string{"step": "build-exector", "status": "failure"})
} else {
ErrorNum += 1
ErrorNum++
i.Logger.Error("从镜像构建应用任务执行失败", map[string]string{"step": "callback", "status": "failure"})
status = "failure"
}
} else {
break
@ -228,7 +227,7 @@ func (e *exectorManager) buildFromSourceCode(in []byte) {
if n < 1 {
i.Logger.Error("从源码构建应用任务执行失败,开始重试", map[string]string{"step": "build-exector", "status": "failure"})
} else {
ErrorNum += 1
ErrorNum++
i.Logger.Error("从源码构建应用任务执行失败", map[string]string{"step": "callback", "status": "failure"})
status = "failure"
}
@ -279,7 +278,7 @@ func (e *exectorManager) buildFromMarketSlug(in []byte) {
if n < 1 {
i.Logger.Error("应用构建失败,开始重试", map[string]string{"step": "builder-exector", "status": "failure"})
} else {
ErrorNum += 1
ErrorNum++
i.Logger.Error("构建应用任务执行失败", map[string]string{"step": "callback", "status": "failure"})
}
} else {
@ -316,7 +315,7 @@ func (e *exectorManager) slugShare(in []byte) {
if n < 1 {
i.Logger.Error("应用分享失败,开始重试", map[string]string{"step": "builder-exector", "status": "failure"})
} else {
ErrorNum += 1
ErrorNum++
i.Logger.Error("分享应用任务执行失败", map[string]string{"step": "builder-exector", "status": "failure"})
status = "failure"
}
@ -357,7 +356,7 @@ func (e *exectorManager) imageShare(in []byte) {
if n < 1 {
i.Logger.Error("应用分享失败,开始重试", map[string]string{"step": "builder-exector", "status": "failure"})
} else {
ErrorNum += 1
ErrorNum++
i.Logger.Error("分享应用任务执行失败", map[string]string{"step": "builder-exector", "status": "failure"})
status = "failure"
}

View File

@ -14,6 +14,7 @@ GetOptions(
"tenant_id|tid=s" => \$tenant_id,
"service_id|sid=s" => \$service_id,
"envs|e=s" => \$envs,
"server_type|st=s" => \$server_type
);
if ($envs) {
@ -25,5 +26,11 @@ if ($envs) {
chdir($source_dir);
#system("git archive master | docker run -i --rm -v $cache_dir:/tmp/cache:rw -a stdin -a stdout goodrain.net/builder - >$package_file");
#system("git archive master | docker run -i --rm -a stdin -a stdout -e SLUG_VERSION=$version -v $slug_dir:/tmp/slug -v $cache_dir:/tmp/cache goodrain.me/builder local >$logfile");
$cmd="git archive $branch | $docker_bin run -i --net=host --rm --name $name -v $cache_dir:/tmp/cache:rw -a stdin -a stdout $APPEND_ENV_STRING -e SLUG_VERSION=$version -e SERVICE_ID=$service_id -e TENANT_ID=$tenant_id -v $slug_dir:/tmp/slug goodrain.me/builder local";
system($cmd);
if ($server_type == svn){
$cmd="tar -c ./ | $docker_bin run -i --net=host --rm --name $name -v $cache_dir:/tmp/cache:rw -a stdin -a stdout $APPEND_ENV_STRING -e SLUG_VERSION=$version -e SERVICE_ID=$service_id -e TENANT_ID=$tenant_id -v $slug_dir:/tmp/slug goodrain.me/builder local";
system($cmd);
}elsif ($server_type == git){
$cmd="git archive $branch | $docker_bin run -i --net=host --rm --name $name -v $cache_dir:/tmp/cache:rw -a stdin -a stdout $APPEND_ENV_STRING -e SLUG_VERSION=$version -e SERVICE_ID=$service_id -e TENANT_ID=$tenant_id -v $slug_dir:/tmp/slug goodrain.me/builder local";
system($cmd);
}