Documentation
¶
Index ¶
- Variables
- func CreateStoreUrls(args []string)
- func Execute()
- func GetBroadcast(name string) (chan string, bool)
- func InitFlags()
- func LoadConfigFile()
- func ReScanPath(storeUrl string, reScanFile bool)
- func RegisterBroadcast(name string) chan string
- func ReloadConfigHandler(e fsnotify.Event)
- func ScanStore(args []string)
- func SetDaemon()
- func SetShutdownHandler()
- func ShowQRCode()
- func ShowQRCodeTailscale(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
var ( DemonFlag bool StopDaemonFlag bool )
DemonFlag 正确地实装,需要理解守护进程的概念 需要去 cmd/init_flags.go 设置flag
var Args []string
var RootCmd = &cobra.Command{ Use: locale.GetString("comigo_use"), Short: locale.GetString("short_description"), Example: locale.GetString("comigo_example"), Version: config.GetVersion(), Long: locale.GetString("long_description"), Run: func(cmd *cobra.Command, args []string) { Args = args config.SetByExecutableFilename() config.AutoSetCacheDir() }, }
RootCmd 没有任何子命令的情况下时的基本命令
var ( // SystemBroadcast 等于 RegisterBroadcast("system") 返回的通道。 SystemBroadcast chan string )
broadcastRegistry 保存所有注册的系统广播通道,key 为自定义名称。 通过 map 的方式可以在不同包中动态注册并复用所需的广播通道。
Functions ¶
func CreateStoreUrls ¶ added in v1.1.0
func CreateStoreUrls(args []string)
CreateStoreUrls 添加默认扫描路径 args[1:]是用户指定的扫描路径
func GetBroadcast ¶ added in v1.0.0
GetBroadcast 返回指定名称的广播通道(只读锁)。
func LoadConfigFile ¶ added in v1.0.0
func LoadConfigFile()
LoadConfigFile 读取顺序:RAM(代码当中设定的默认值)+命令行参数 -> HomeDirectory -> ProgramDirectory -> WorkingDirectory
func ReScanPath ¶
ReScanPath 重新扫描目录,因为需要设置下载路径,gin 初始化后才能执行
func RegisterBroadcast ¶ added in v1.0.0
RegisterBroadcast 创建或返回一个已存在的广播通道。 不同模块可以调用此方法注册/获取自己的通道,实现解耦。
func ReloadConfigHandler ¶ added in v1.1.0
监听配置文件变更 优雅地重启或停止 https://learnku.com/docs/gin-gonic/1.7/examples-graceful-restart-or-stop/11376
func SetDaemon ¶ added in v1.0.0
func SetDaemon()
SetDaemon 设置守护进程, To terminate the daemon use: kill `cat comigo.pid` 该函数会在Unix系统上将当前进程转化为守护进程,并在后台运行。 如果当前系统不是Unix系统,或者没有指定启动或停止守护进程的参数,则直接返回。 https://github.com/sevlyar/go-daemon https://github.com/sevlyar/go-daemon/blob/v0.1.6/examples/cmd/gd-simple/simple.go go run main.go --start go run main.go --stop
func ShowQRCode ¶ added in v1.0.0
func ShowQRCode()
func ShowQRCodeTailscale ¶ added in v1.1.0
ShowQRCodeTailscale 打印 Tailscale 访问地址的二维码
Types ¶
This section is empty.