hnhdigital-os/fs-watcher

提供监视文件夹变化并调用二进制文件的能力。

2.0.5 2021-03-31 06:07 UTC

README

提供监视文件夹变化并调用二进制文件的能力。

Latest Stable Version License: MIT Donate to this project using Patreon

此包由澳大利亚精品开发商H&H|Digital开发。访问我们的网站 hnh.digital

需求

  • PHP 7.3 (最小)
  • php-inotify (pecl install inotify)

安装

下载最新构建

curl -o ./fs-watcher -LsS https://github.com/hnhdigital-os/fs-watcher/raw/master/builds/fs-watcher

chmod a+x ./fs-watcher

移动到本地bin

sudo mv ./fs-watcher /usr/local/bin/fs-watcher

更新

此工具提供自更新机制。只需运行自更新命令。

fs-watcher self-update

如何使用

USAGE: fs-watcher <command> [options] [arguments]
  config           <set|get|reset> [key] [value]
                   Manage the configuration for this utility.

  self-update      Check if there is a new version and update.
  self-update      [--tag=?]
                   Update this binary to a specific tagged release.
  self-update      [--check-release=?]
                   Returns the current binary version.
  watch:now        [watch-path] [binary-path] [--script-arguments=""]
                   Specify the path to watch, when a file change is detected
                   this utility will call the specified binary at the path with the
                   specific script arguments.
  watch:background [watch-path] [binary-path] [--script-arguments=""]
                   Runs process in the background. Specify the path to watch,
                   when a file change is detected this utility will call the
                   specified binary at the path with the specific script arguments.
  watch:load       Load watchers from a config file.
  watch:list       List all current watchers.
  watch:kill       [pid]
                   Kill a specific process ID for a current watcher.
  watch:kill all   Kills all the watchers.
  watch:log        [pid]
                   View the current log for a specific process ID.
  watch:log        [--where]
                   Returns the path of the log files.
  watch:log        [pid] [--clear]
                   Clears the logs for a specific process ID.
  watch:log        [--clear]
                   Clears all the logs.

watch:now 或 watch:background

例如,如果我们想监视 /some/folder/example 路径中的变化,并将所有更改通知给可执行文件 /some/bin/binary-file

注意:此实用程序将在脚本参数中使用值替换以下占位符 {{root-path}}、{{file-path}} 和 {{event-id}}。路径参数不需要引号,因为它们将被自动添加。

fs-watcher watch:background /some/folder/example /some/bin/binary-file --script-arguments="{{root-path}} {{file-path}} {{event-id}}"

在指定的根文件夹中的每个文件更改时,将执行以下命令

/some/bin/binary-file "/some/folder/example" "/some/folder/example/new-file" 256

watch:load

您可以使用 watch:load 命令加载 YAML 配置文件,而不是为每个要监视的文件夹调用此实用程序。

此配置文件格式如下

WATCH-PATH:
 - BINARY-PATH: SCRIPT-ARGUMENTS

示例

/some/folder/example:
 - /some/bin/binary-file: {{root-path}} {{file-path}} {{event-id}}

然后运行以下命令以加载和启动监视器

fs-watcher watch:load example.yml

贡献

有关详细信息,请参阅 CONTRIBUTING

致谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件