@acter/sentinel 中文文档教程
sentinel
监视文件夹并在满足条件时执行操作。
Setting up as a service
Sentinel 可以使用许多守护进程管理器作为服务运行。 以下是一些建议:
windows
nssm
Linux / Mac
forever
Configuration
Sentinel 可以使用 JSON、JSON5、YML 甚至 JavaScript 文件进行配置。 您可以通过简单地使用相应的名称命名默认配置文件来指定输入格式 扩展名(.json、.json5、.yml 或 .js)。
您可以通过设置环境变量来指定 Sentinel 应该在哪里获取它的配置 SENTINEL_CONFIG_DIR
到你的配置文件所在的文件夹,否则 Sentinel 将 在当前文件夹的根目录中查找名为 config 的文件夹。
Container and orchistration considerations
因为 Sentinel 可以从任何地方获取配置,所以你可以简单地为它提供一个配置目录 docker 环境设置,但 Sentinel 可以更进一步。 如果你指定一个标准 NODE_ENV
环境变量,你也可以告诉哨兵在特定的配置之间切换 在整个您共享的相同配置文件夹中的环境配置 平台。
例如,如果您将 NODE_ENV
设置为“production”,sentinel 将查找名为 'production',如果将其设置为'development',ir 将查找名为'development' 的文件,等等 向前。 这样,您就可以配置 Sentinel 实例以不同方式配置自己 通过环境并分发相同的文件(使用 NODE_ENV
)或只是使用不同的 通过 SENTINEL_CONFIG_DIR
的文件夹。 由你决定。
Debuggging
Sentinel 支持广泛的调试,以防出现问题。 配置调试通过 DEBUG
环境变量,或在配置选项中设置调试路径。
如果将调试路径设置为“”,则所有发生的事情都会被输出。 如果你只想 记录一组特定的事件,使用通配符。 例如,如果你只想调试 sentinel 监视函数,使用“sentinel:watch:”。 如果您只想观看哨兵触发器,请使用 “sentinel:trigger:*”等。这里是调试路径的完整列表以及它们的作用……
sentinel
任何应用程序级事件,如加载、启动和停止。
sentinel:watch
为简单起见,在 YML 中给出了发生的任何观察事件
Configuration options
示例。
sentinel
Watches a folder and does things when criteria is met.
Setting up as a service
Sentinel can run as a service using many daemon managers. Here are some recommendations:
windows
nssm
Linux / Mac
forever
Configuration
Sentinel can be configured using JSON, JSON5, YML or even JavaScript files for configuration. You specifiy the input format by simply naming your default config file with the respective extension (.json, .json5, .yml or .js).
You can specify where Sentinel should get it's config by setting the environment variable SENTINEL_CONFIG_DIR
to the folder your configuration file is located, otherwise Sentinel will look for a folder called config in the root of it's current folder.
Container and orchistration considerations
Because Sentinel can get configuration from anywhere, you can simply provide it a config dir through docker environment settings, but Sentinel can go further than that. If you specify a standard NODE_ENV
environment variable, you can also tell sentinel to switch config between specific environment configurations within an indentical configuration folder shared throughout your platform.
For example, if you set NODE_ENV
to 'production' sentinel will look for a config file called 'production', if you set it to 'development' ir will look for a file called 'development', and so forth. In this way, you can both configure Sentinel instances to configure themselves differently through the environment and distribute identical files (using NODE_ENV
) or just use different folders through SENTINEL_CONFIG_DIR
. It's up to you.
Debuggging
Sentinel supports extensive debugging in case something goes wrong. Configure debugging through the DEBUG
environment variable, or set the debug path in configuration options.
If you set the debug path to "", everything that happens will be outputted. If you only want to log a particular set of events, use wildcards. For example, if you only want to debug sentinel watch functions, use "sentinel:watch:". If you only want to watch sentinel triggers, use "sentinel:trigger:*", etc. Here is a complete list of debug paths and what they do…
sentinel
Any application level events like loading, starting and stopping.
sentinel:watch
Any watch events that took place
Configuration options
Examples are given in YML for simplicity.