コード例 #1
0
ファイル: client.go プロジェクト: gethinzhang/crawler
func main() {
	app := cli.NewApp()
	app.Name = "novel_client"
	app.Usage = "novel client function aggregation"
	app.Version = VERSION

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "path, d",
			Value: "conf",
			Usage: "conf directory of client",
		},
		cli.StringFlag{
			Name:  "file, f",
			Value: "client.conf",
			Usage: "config file of client",
		},
	}

	app.Commands = []cli.Command{
		{
			Name:  "grab",
			Usage: "grab commands, including site|novel|chapter",
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "wait, w",
					Usage: "if wait for result",
				},
			},
			Subcommands: []cli.Command{
				{
					Name:        "site",
					Usage:       "send grab site commands",
					Description: "[egg: tyread.com]",
					Action: func(c *cli.Context) {
						Init(c.GlobalString("path"), c.GlobalString("file"))
						site := c.Args().Get(0)
						if site == "" {
							cli.ShowCommandHelp(c, "site")
							os.Exit(-1)
						}

						GrabSite(site, c.GlobalBool("wait"))
					},
				},
			},
		},
	}
	app.Action = func(c *cli.Context) {
		cli.ShowAppHelp(c)
	}

	app.Run(os.Args)
	defer env.Close()
}
コード例 #2
0
func main() {
	if err := env.Load("conf", "scheduler.conf"); err != nil {
		panic(err.Error())
	}
	defer env.Close()

	sch, err := scheduler.NewScheduler()
	if err != nil {
		panic("init scheduler error: " + err.Error())
	}

	sch.Work()

}
コード例 #3
0
func main() {
	var svr *saver.Saver
	var err error

	if err := env.Load("conf", "saver.conf"); err != nil {
		panic(err.Error())
	}
	defer env.Close()

	if svr, err = saver.NewSaver(); err != nil {
		panic("init saver error : " + err.Error())
	}

	svr.Work()
}