예제 #1
0
파일: main.go 프로젝트: yubo/falcon
func init() {
	host, _ := os.Hostname()

	flag.StringVar(&pidfile, "p", "/tmp/ctrl.pid", "pid file path")
	flag.IntVar(&ct.Params.Debug, "d", 0, "debug level")
	flag.StringVar(&ct.Params.Host, "host", host, "hostname")
	flag.BoolVar(&ct.Params.Rpc, "rpc", true, "enable rpc")
	flag.BoolVar(&ct.Params.Http, "http", false, "enable http")
	flag.StringVar(&ct.Params.RpcAddr, "ra", "127.0.0.1:1988", "rpc addr")
	flag.StringVar(&ct.Params.HttpAddr, "ha", "127.0.0.1:1989", "http addr")
	flag.StringVar(&opts.ConfigFile, "config",
		"./conf/app.conf", "ctrl config file")

	beego.BConfig.AppName = opts.ConfigFile

	flags.CommandLine.Usage = fmt.Sprintf("Usage: %s [OPTIONS] COMMAND ",
		"start|stop\n", os.Args[0])

	flags.NewCommand("start", "start agent",
		start, flag.ExitOnError)

	flags.NewCommand("stop", "stop agent",
		stop, flag.ExitOnError)

	flags.NewCommand("help", "show help information",
		help, flag.ExitOnError)
}
예제 #2
0
파일: falcon.go 프로젝트: yubo/falcon
func init() {
	flags.NewCommand("start", "start falcon",
		start, flag.ExitOnError)

	flags.NewCommand("stop", "stop falcon",
		stop, flag.ExitOnError)

	flags.NewCommand("parse", "just parse falcon ConfigFile",
		parse, flag.ExitOnError)

	flags.NewCommand("reload", "reload falcon",
		reload, flag.ExitOnError)

}
예제 #3
0
파일: command.go 프로젝트: DeanChina/gotty
func init() {
	flags.CommandLine.Usage = fmt.Sprintf("Usage: %s [OPTIONS] COMMAND [arg...]\n"+
		"       %s [OPTIONS] URL\n\n"+
		"Share your terminal as a web application",
		os.Args[0], os.Args[0])
	flags.CommandLine.Name = "gotty"

	// Global options
	flag.StringVar(&configFile, "c",
		"/etc/gotty/gotty.conf", "Config file path")
	flag.BoolVar(&GlobalOpt.SkipTlsVerify, "skip-tls-verify",
		DefaultOptions.SkipTlsVerify, "Skip TLS verify")

	// daemon
	cmd := flags.NewCommand("daemon", "Enable daemon mode",
		daemon_handle, flag.ExitOnError)

	// exec
	cmd = flags.NewCommand("exec", "Run a command in a new pty",
		exec_handle, flag.ExitOnError)
	cmd.BoolVar(&CmdOpt.PermitWrite, "w",
		DefaultCmdOptions.PermitWrite,
		"Permit clients to write to the TTY (BE CAREFUL)")
	cmd.BoolVar(&CmdOpt.PermitShare, "share",
		DefaultCmdOptions.PermitShare,
		"Allow muilt-clients to join the TTY (addr should be network or muilt-addr)")
	cmd.BoolVar(&CmdOpt.PermitShareWrite, "share-write",
		DefaultCmdOptions.PermitShareWrite,
		"Permit joined clients to wirte to the TTY if this TTY writable(BE CAREFULL)")
	cmd.StringVar(&CmdOpt.Name, "name", "", "set tty session name")
	cmd.StringVar(&CmdOpt.Addr, "addr", DefaultCmdOptions.Addr,
		"allow access nets, e.g. 127.0.0.1,192.168.0.0/24")
	cmd.BoolVar(&CmdOpt.Rec, "rec",
		DefaultCmdOptions.Rec, "record tty and save")

	// ps
	cmd = flags.NewCommand("ps", "List session",
		ps_handle, flag.ExitOnError)
	cmd.BoolVar(&CmdOpt.All, "a", DefaultCmdOptions.All,
		"Show all session(default show just "+
			CONN_S_CONNECTED+"/"+CONN_S_WAITING+")")

	// attach
	cmd = flags.NewCommand("attach", "Attach to a seesion",
		attach_handle, flag.ExitOnError)
	cmd.BoolVar(&CmdOpt.PermitWrite, "w",
		DefaultCmdOptions.PermitWrite,
		"Permit clients to write to the TTY (BE CAREFUL)")
	cmd.StringVar(&CmdOpt.Name, "name", "", "set the new session name")
	cmd.StringVar(&CmdOpt.Addr, "addr",
		DefaultCmdOptions.Addr, "allow ipv4 address")
	cmd.StringVar(&CmdOpt.SName, "sname", "", "attach to the session name")
	cmd.StringVar(&CmdOpt.SAddr, "saddr",
		DefaultCmdOptions.Addr, "attach to the session addr")

	// close
	cmd = flags.NewCommand("close", "Close a pty/session",
		close_handle, flag.ExitOnError)
	cmd.StringVar(&CmdOpt.Name, "name", "", "set tty session name")
	cmd.StringVar(&CmdOpt.Addr, "addr", DefaultCmdOptions.Addr,
		"allow access nets, e.g. 127.0.0.1,192.168.0.0/24")
	cmd.BoolVar(&CmdOpt.All, "a", false,
		"Close all session use the same pty(default close just a seesion)")

	// play
	cmd = flags.NewCommand("play",
		"replay recorded file in a webtty",
		play_handle, flag.ExitOnError)
	cmd.StringVar(&CmdOpt.SName, "i", "", "play input id/filename in current tty")
	cmd.StringVar(&CmdOpt.Name, "name", "", "set tty session name")
	cmd.StringVar(&CmdOpt.Addr, "addr",
		DefaultCmdOptions.Addr,
		"allow access nets, e.g. 127.0.0.1,192.168.0.0/24")
	cmd.StringVar(&CmdOpt.RecId, "id", "", "replay tty id")
	cmd.Float64Var(&CmdOpt.Speed, "speed",
		DefaultCmdOptions.Speed, "replay speed")
	cmd.BoolVar(&CmdOpt.Repeat, "repeat",
		DefaultCmdOptions.Repeat, "replay repeat")
	cmd.BoolVar(&CmdOpt.PermitShare, "share",
		DefaultCmdOptions.PermitShare,
		"Allow muilt-clients to join the TTY (addr should be network or muilt-addr)")
	cmd.Int64Var(&CmdOpt.MaxWait, "max-wait",
		DefaultCmdOptions.MaxWait,
		"Reduce recorded terminal inactivity to max <sec> second")

	cmd = flags.NewCommand("convert",
		"convert seesion id to asciicast format(json)", convert_handle, flag.ExitOnError)
	cmd.StringVar(&CmdOpt.SName, "i", "", "convert tty, input filename or seesion id")
	cmd.StringVar(&CmdOpt.Name, "o", "out.json", "convert tty, output filename")
	cmd.Int64Var(&CmdOpt.MaxWait, "max-wait",
		DefaultCmdOptions.MaxWait,
		"Reduce recorded terminal inactivity to max <sec> second")

	// version
	cmd = flags.NewCommand("version",
		"Show the gotty version information", version_handle, flag.ExitOnError)

}