diff --git a/README.md b/README.md index 164a7c4..2ed916a 100644 --- a/README.md +++ b/README.md @@ -130,19 +130,6 @@ command: # 如果不需要该特性,设置为 0 delayMillSecond: 2000 - # 特殊指令 - # 可以通过预定义的指令来控制 command 的行为,指令可以有多个 - # exec-when-start fileboy启动就绪后,自动执行一次 'exec' 定义的命令 - # should-finish 触发执行 'exec' 时(C),如果上一次的命令(L)未退出(还在执行),会等待 L 退出,直到有明确 exit code 才会开始执行本次命令。 - # 在等待 L 退出时,又有新事件触发了命令执行(N),则 C 执行取消,只会保留最后一次的 N 执行 - # ignore-stdout 执行 'exec' 产生的 stdout 会被丢弃 - # ignore-warn fileboy 自身的 warn 信息会被丢弃 - # ignore-info fileboy 自身的 info 信息会被丢弃 - # ignore-exec-error 执行 'exec' 出错仍继续执行下面的命令而不退出 - instruction: - #- should-finish - #- exec-when-start - # 通知器 notifier: # 文件更改会向该 url 发送请求(POST 一段 json 文本数据) @@ -155,6 +142,22 @@ notifier: # 例: http://example.com/notifier/fileboy-listener # 不启用通知,请留空 "" callUrl: "" + +# 特殊指令 +instruction: + # 可以通过特殊的指令选项来控制 command 的行为,指令可以有多个 + # 指令选项解释: + # exec-when-start fileboy启动就绪后,自动执行一次 'exec' 定义的命令 + # should-finish 触发执行 'exec' 时(C),如果上一次的命令(L)未退出(还在执行),会等待 L 退出(而不是强制 kill ),直到 L 有明确 exit code 才会开始执行本次命令。 + # 在等待 L 退出时,又有新事件触发了命令执行(N),则 C 执行取消,只会保留最后一次的 N 执行 + # ignore-stdout 执行 'exec' 产生的 stdout 会被丢弃 + # ignore-warn fileboy 自身的 warn 信息会被丢弃 + # ignore-info fileboy 自身的 info 信息会被丢弃 + # ignore-exec-error 执行 'exec' 出错仍继续执行下面的命令而不退出 + + #- should-finish + #- exec-when-start + - ignore-warn ``` ### TODO diff --git a/README_EN.md b/README_EN.md index cf33cdb..7a643b6 100644 --- a/README_EN.md +++ b/README_EN.md @@ -127,19 +127,6 @@ command: # If this feature is not required, set to 0 delayMillSecond: 2000 - # 特殊指令 - # 可以通过预定义的指令来控制 command 的行为,指令可以有多个 - # exec-when-start fileboy启动就绪后,自动执行一次 'exec' 定义的命令 - # should-finish 触发执行 'exec' 时(C),如果上一次的命令(L)未退出(还在执行),会等待 L 退出,直到有明确 exit code 才会开始执行本次命令。 - # 在等待 L 退出时,又有新事件触发了命令执行(N),则 C 执行取消,只会保留最后一次的 N 执行 - # ignore-stdout 执行 'exec' 产生的 stdout 会被丢弃 - # ignore-warn fileboy 自身的 warn 信息会被丢弃 - # ignore-info fileboy 自身的 info 信息会被丢弃 - # ignore-exec-error 执行 'exec' 出错仍继续执行下面的命令而不退出 - instruction: - #- should-finish - #- exec-when-start - notifier: # file changes send requests to the URL (POST JSON text data) # the timing of triggering the request is consistent with executing the command command @@ -151,6 +138,22 @@ notifier: # e.g: http://example.com/notifier/fileboy-listener # no notice is enabled. Please leave it blank. "" callUrl: "" + +instruction: + # command behavior can be controlled by special command options. there can be multiple instructions + # options: + # exec-when-start when fileboy is ready to start, execute the command defined by 'exec' once automatically + # should-finish when the execution of 'exec' is triggered (C), if the last command (L) does not exit (still executing), + # it will wait for L to exit (instead of forcing kill), and the execution of this command will not start until L has an explicit exit code. + # when waiting for L to exit, and a new event triggers command execution (n), C execution is cancelled, and only the last N execution is retained + # ignore-stdout stdout generated by executing 'exec' will be discarded + # ignore-warn the warn information of fileboy itself will be discarded + # ignore-info the info information of fileboy itself will be discarded + # ignore-exec-error error executing 'exec' continue to execute the following command without exiting + + #- should-finish + #- exec-when-start + - ignore-warn ``` ### CONTRIBUTOR diff --git a/fileboy.go b/fileboy.go index b74ea5c..e7951e6 100644 --- a/fileboy.go +++ b/fileboy.go @@ -73,13 +73,13 @@ func parseConfig() { cfg.Monitor.IncludeDirsMap = map[string]bool{} cfg.Monitor.ExceptDirsMap = map[string]bool{} cfg.Monitor.IncludeDirsRec = map[string]bool{} - cfg.Command.InstructionMap = map[string]bool{} + cfg.InstructionMap = map[string]bool{} // convert to map for _, v := range cfg.Monitor.Types { cfg.Monitor.TypesMap[v] = true } - for _, v := range cfg.Command.Instruction { - cfg.Command.InstructionMap[v] = true + for _, v := range cfg.Instruction { + cfg.InstructionMap[v] = true } log.Printf("%+v", cfg) } diff --git a/filegirl.go b/filegirl.go index 86f305c..f20fd39 100644 --- a/filegirl.go +++ b/filegirl.go @@ -18,14 +18,14 @@ type FileGirl struct { IncludeDirsRec map[string]bool `yaml:"-"` } Command struct { - Instruction []string `yaml:"instruction"` Exec []string `yaml:"exec"` DelayMillSecond int `yaml:"delayMillSecond"` - - // convert to - InstructionMap map[string]bool `yaml:"-"` } Notifier struct { CallUrl string `yaml:"callUrl"` } + Instruction []string `yaml:"instruction"` + + // convert to + InstructionMap map[string]bool `yaml:"-"` } diff --git a/raw.go b/raw.go index 4d4c697..39637c2 100644 --- a/raw.go +++ b/raw.go @@ -69,19 +69,6 @@ command: # 如果不需要该特性,设置为 0 delayMillSecond: 2000 - # 特殊指令 - # 可以通过预定义的指令来控制 command 的行为,指令可以有多个 - # exec-when-start fileboy启动就绪后,自动执行一次 'exec' 定义的命令 - # should-finish 触发执行 'exec' 时(C),如果上一次的命令(L)未退出(还在执行),会等待 L 退出,直到有明确 exit code 才会开始执行本次命令。 - # 在等待 L 退出时,又有新事件触发了命令执行(N),则 C 执行取消,只会保留最后一次的 N 执行 - # ignore-stdout 执行 'exec' 产生的 stdout 会被丢弃 - # ignore-warn fileboy 自身的 warn 信息会被丢弃 - # ignore-info fileboy 自身的 info 信息会被丢弃 - # ignore-exec-error 执行 'exec' 出错仍继续执行下面的命令而不退出 - instruction: - #- should-finish - #- exec-when-start - # 通知器 notifier: # 文件更改会向该 url 发送请求(POST 一段 json 文本数据) @@ -94,6 +81,22 @@ notifier: # 例: http://example.com/notifier/fileboy-listener # 不启用通知,请留空 "" callUrl: "" + +# 特殊指令 +instruction: + # 可以通过特殊的指令选项来控制 command 的行为,指令可以有多个 + # 指令选项解释: + # exec-when-start fileboy启动就绪后,自动执行一次 'exec' 定义的命令 + # should-finish 触发执行 'exec' 时(C),如果上一次的命令(L)未退出(还在执行),会等待 L 退出(而不是强制 kill ),直到 L 有明确 exit code 才会开始执行本次命令。 + # 在等待 L 退出时,又有新事件触发了命令执行(N),则 C 执行取消,只会保留最后一次的 N 执行 + # ignore-stdout 执行 'exec' 产生的 stdout 会被丢弃 + # ignore-warn fileboy 自身的 warn 信息会被丢弃 + # ignore-info fileboy 自身的 info 信息会被丢弃 + # ignore-exec-error 执行 'exec' 出错仍继续执行下面的命令而不退出 + + #- should-finish + #- exec-when-start + - ignore-warn ` var firstRunHelp = `第一次运行 fileboy ? diff --git a/util.go b/util.go index c7ebd99..40ddb48 100644 --- a/util.go +++ b/util.go @@ -14,7 +14,7 @@ func keyInMonitorTypesMap(k string, cfg *FileGirl) bool { } func keyInInstruction(k string) bool { - _, ok := cfg.Command.InstructionMap[k] + _, ok := cfg.InstructionMap[k] return ok }