示例#1
0
// Run agent inside current process
// Start httptest local server
func RunInternalAgent(app http.Handler) error {
	ts := httptest.NewServer(app)
	hostname, err := utils.GetHostname()
	if err != nil {
		return err
	}
	api := client.NewClient(fmt.Sprintf("%s/api/", ts.URL), nil)
	api.Token = "agent-token"
	go func() {
		agent.ServeAgent(hostname, api)
	}()
	return nil
}
示例#2
0
文件: agent.go 项目: iwarsong/bearded
func agentAction(ctx *cli.Context, api *client.Client) {

	var agentName string
	if agentName = ctx.String("name"); agentName == "" {
		hostname, err := utils.GetHostname()
		if err != nil {
			panic(err)
		}
		agentName = hostname
	}
	err := ServeAgent(agentName, api)
	logrus.Error(err)
}