server

package
v0.0.0-...-a3600d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateHandler handler.HandlerTablesFunc = func(table []*common.Table) {

	beego.Debug("CreateHandler")

	if true {
		beego.Debug("Start Prepare ......")
		req := demo.CreateReq{table}
		tableBytes, e := json.Marshal(req)
		if e != nil {
			panic(e)
		}
		now := common.GetNowTimeYYYYMMDDhhmmss()
		tempPath := cfg.Cfg.GetServerTempPath() + now + "/"
		distPath := cfg.Cfg.DistPath
		e = os.MkdirAll(tempPath, os.ModePerm)

		if e != nil {
			panic(e)
		}
		dataFilePath := tempPath + "data.json"
		e = ioutil.WriteFile(dataFilePath, tableBytes, os.ModePerm)
		if e != nil {
			panic(e)
		}

		filenames := []string{"data", "cfg"}
		filepaths := []string{dataFilePath, common.CmdParam.CfgPath}

		if e != nil {
			beego.Error(e)
		} else {

		}
		params := make(map[string]string)
		params["build"] = common.CmdParam.BuildType
		params["email"] = common.CmdParam.Email
		beego.Debug("Prepare Done!")

		beego.Debug("Start Build ......")
		resp, e := handler.PostFiles(common.CreateAllUrl, params, filenames, filepaths)

		if e != nil {
			panic(e)
		}

		resBytes, e := ioutil.ReadAll(resp.Body)

		if resp.StatusCode != 200 {
			logs.Error("response => ", string(resBytes))
			panic(resp.Status)
		}

		resObj := demo.CreateRes{}
		e = json.Unmarshal(resBytes, &resObj)
		if e != nil {
			panic(e)
		}

		svrZipPath := tempPath + cfg.Cfg.GetServerProjcetName() + ".zip"
		webZipPath := tempPath + cfg.Cfg.GetWebProjcetName() + ".zip"
		easyWebZipPath := tempPath + "easyweb.zip"

		beego.Debug("Build Done !")

		beego.Debug("Start Write ......")

		if resObj.Result == 0 {

			token := make(chan int, 3)
			go func() {

				beego.Debug("Start Write Svr......")
				if resObj.Body.SvrZipUrl != "" {
					handler.DownloadFile(resObj.Body.SvrZipUrl, svrZipPath)

					handler.Unzip(svrZipPath, distPath)
				}
				beego.Debug("Write Svr Done!")
				token <- 1
			}()

			go func() {

				beego.Debug("Start Write Web......")
				if resObj.Body.WebZipUrl != "" {
					handler.DownloadFile(resObj.Body.WebZipUrl, webZipPath)

					handler.Unzip(webZipPath, distPath)
				}
				beego.Debug("Write Web Done!")
				token <- 1
			}()

			go func() {
				beego.Debug("Start Write EasyWeb......")
				handler.DownloadFile(common.EaseWebZipUrl, easyWebZipPath)
				handler.Unzip(easyWebZipPath, distPath)
				beego.Debug("Write EasyWeb Done!")
				token <- 1
			}()

			<-token
			<-token
			<-token
		}
		beego.Debug("Write Done!")
		beego.Debug(resObj.Message)

	}

}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL