// 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 }
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) }