示例#1
0
func TestAgentCommand(t *testing.T) {
	mailbox.OpenMemDB()
	key := mailbox.AccessKey{FullAccess: true}
	key.Create()
	agent.Address = ":6112"
	agent.AccessKey = key.Secret
	go agent.Start()
	engine.Agents["test"] = ":6112"
	engine.AgentAccessKey = key.Secret
	eng := engine.New()
	err := eng.Execute(`$agent("test", function() { console.log("test"); });`)
	if err != nil {
		t.Fatal(err)
	}
}
示例#2
0
文件: agent.go 项目: 5Sigma/Conduit
To run as an agent an address and port must be specified in the config file.
This is the interface and port to listen on. It should match the configuration
on the handler. For example:

agent_host: 10.0.100.15:2222

Agents must also have the same access_key as their handler in the config file.`,
	Run: func(cmd *cobra.Command, args []string) {
		agent.Address = viper.GetString("agent_host")
		agent.AccessKey = viper.GetString("access_key")
		if agent.Address == "" {
			cmd.Help()
			log.Fatal("\nThe 'agent_host' field in the config file is not present.")
		}
		log.Info("Starting agent on " + agent.Address)
		agent.Start()
	},
}

func init() {
	RootCmd.AddCommand(agentCmd)

	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// agentCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// agentCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")