-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
本地开发环境搭建的简易教程 #484
Comments
我貌似找到了切入点,等我研究下, ### |
修改falcon-plus/cmd/start.go // 编译运行golang 文件
func MyExec(path string, buildName string) error {
logrus.SetLevel(logrus.DebugLevel)
logrus.Debug("start")
config := cmdArgs(buildName)
// 移除之前生成的二进制文件
buildName = "build/" + buildName
if _, err := os.Stat(buildName); err == nil {
os.Remove(buildName)
}
os.Remove(buildName)
mainFilePath := []string{"build", "-o", buildName}
mainFilePath = append(mainFilePath, path)
buildCommand := exec.Command("/usr/local/Cellar/go/1.9.4/bin/go", mainFilePath...)
buildCommand.Stdout = os.Stdout
buildCommand.Stderr = os.Stderr
err := buildCommand.Run()
if err == nil {
logrus.Debug("编译完成")
buildFilePath := fmt.Sprintf("./%s", buildName)
logrus.Debug(buildFilePath)
runCommand := exec.Command(buildFilePath, config...)
runCommand.Stdout = os.Stdout
runCommand.Stderr = os.Stderr
logrus.Debug("开始run")
err = runCommand.Start()
if err == nil {
logrus.Debug("成功运行")
return nil
} else {
logrus.Debug("运行出错 %", err)
return err
}
}
logrus.Debug("编译出错 ", err)
return err
} #####2. 在start.go 的execModule 方法中调用这个方法,相应的这个方法也需要修改下. func execModule(co bool, name string) error {
// go build
//res := cmdArgs(name)
//cmd := exec.Command(g.Bin(name), cmdArgs(name)...)
//if co {
// cmd.Stdout = os.Stdout
// cmd.Stderr = os.Stderr
// return cmd.Run()
//
//}
// add
logrus.Debug(g.Bin(name))
logrus.Debug(cmdArgs(name))
res := strings.Split(g.Bin(name), "/")
re := res[len(res)-2]
err := MyExec(g.Bin(name), re)
logrus.Debug("!!!!!!")
// end
logOutput, err := openLogFile(name)
if err != nil {
return err
}
defer logOutput.Close()
//cmd.Stdout = logOutput
//cmd.Stderr = logOutput
//return cmd.Start()
return err
} #####3. 用户这些文件读取的配置都是在g/g.go 这个文件中,因此我们需要对这个文件中的内容也要做些修改 func init() {
Modules = map[string]bool{
//"agent": true,
//"aggregator": true,
"graph": true,
"hbs": true,
//"judge": true,
//"nodata": true,
//"transfer": true,
//"gateway": true,
//"api": true,
//"alarm": true,
}
BinOf = map[string]string{
//"agent": "./agent/bin/falcon-agent",
//"aggregator": "./aggregator/bin/falcon-aggregator",
"graph": "./modules/graph/main.go",
"hbs": "./modules/hbs/main.go",
//"judge": "./judge/bin/falcon-judge",
//"nodata": "./nodata/bin/falcon-nodata",
//"transfer": "./transfer/bin/falcon-transfer",
//"gateway": "./gateway/bin/falcon-gateway",
//"api": "./api/bin/falcon-api",
//"alarm": "./alarm/bin/falcon-alarm",
}
//modules/graph
cfgOf = map[string]string{
//"agent": "./agent/config/cfg.json",
//"aggregator": "./aggregator/config/cfg.json",
"graph": "./modules/graph/config/cfg.json", // 添加cfg.json 的位置,这里你可以根据需求配置对应的位置
"hbs": "./modules/hbs/config/cfg.json",
//"judge": "./judge/config/cfg.json",
//"nodata": "./nodata/config/cfg.json",
//"transfer": "./transfer/config/cfg.json",
//"gateway": "./gateway/config/cfg.json",
//"api": "./api/config/cfg.json",
//"alarm": "./alarm/config/cfg.json",
}
ModuleApps = map[string]string{
//"agent": "falcon-agent",
//"aggregator": "falcon-aggregator",
"graph": "graph", // 这里对应着build 之后的二进制文件名称
"hbs": "hbs",
//"judge": "falcon-judge",
//"nodata": "falcon-nodata",
//"transfer": "falcon-transfer",
//"gateway": "falcon-gateway",
//"api": "falcon-api",
//"alarm": "falcon-alarm",
}
logpathOf = map[string]string{
//"agent": "./agent/logs/agent.log",
//"aggregator": "./aggregator/logs/aggregator.log",
"graph": "./logs/graph.log", // log存放位置
"hbs": "./logs/hbs.log",
//"judge": "./judge/logs/judge.log",
//"nodata": "./nodata/logs/nodata.log",
//"transfer": "./transfer/logs/transfer.log",
//"gateway": "./gateway/logs/gateway.log",
//"api": "./api/logs/api.log",
//"alarm": "./alarm/logs/alarm.log",
}
PidOf = map[string]string{
//"agent": "<NOT SET>",
//"aggregator": "<NOT SET>",
"graph": "<NOT SET>",
"hbs": "<NOT SET>",
//"judge": "<NOT SET>",
//"nodata": "<NOT SET>",
//"transfer": "<NOT SET>",
//"gateway": "<NOT SET>",
//"api": "<NOT SET>",
//"alarm": "<NOT SET>",
}
// Modules are deployed in this order
AllModulesInOrder = []string{
"graph",
"hbs",
//"judge",
//"transfer",
//"nodata",
//"aggregator",
//"agent",
//"gateway",
//"api",
//"alarm",
}
} 最后你就可以把这些服务直接跑起来了, |
完结撒花。。。。。。 |
|
@bingqianglin make pack的方式可以解决你的需求么?你可以看看makefile |
@MistShi 谢谢啦,我已经解决了。 |
可以出一个本地开发环境搭建的简易教程吗, 想仔细研究下代码的实现,但是一直卡在代码的运行中,我看github的目录结构和编译之后的目录结构是不一样的,想请教下本地的代码应该怎么运行起来?谢谢
The text was updated successfully, but these errors were encountered: