加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 905 Bytes
一键复制 编辑 原始数据 按行查看 历史
chenlei_git 提交于 2024-05-08 19:25 . first commit
package main
import (
"flag"
"github.com/go-cinch/common/log"
"go-tiktok-scrapy/workers"
"os"
"os/signal"
"syscall"
)
var workerMap map[string]func(count int) = map[string]func(count int){
"tiktok": workers.RunTikTokWorker,
"tiktok-exp": workers.RunTikTokExploreWorker,
}
func main() {
shutdown := make(chan int)
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
go func() {
<-sigChan
log.Info("Shutting down...")
shutdown <- 1
}()
var worker string
var isServer bool
var count int
flag.BoolVar(&isServer, "s", false, "Run as server")
flag.StringVar(&worker, "w", "tiktok", "Choose the worker to run")
flag.IntVar(&count, "c", 20, "Number of workers to run")
flag.Parse()
if isServer {
go Server()
} else {
f, ok := workerMap[worker]
if !ok {
panic("worker not found")
}
f(count)
}
<-shutdown
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化