[{"id":"bcb0874d-299b-448e-9552-9e9b25ef80dd","tags":[{"product":null,"links":null,"id":"ba7e818e-4f6b-4211-b1ac-58e3bafcf439","name":"\u66F4\u65B0","color":"orange","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8ce3627e-9e58-471b-9133-4f135d191e7b","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"ae60ae59-34f5-4f32-a8eb-243ed1457543","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"3d4848c3-910f-4ffa-9153-60bb507334a9","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"133f4ca6-d951-4d65-a618-3dc6301266f7","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"de62ec1c-813e-40b1-8160-a4cd109afe64","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2426c71d-8332-4cbd-a436-1ec4f8666464","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2ce7b6b0-78aa-4e4b-bf8a-e4ba2f988298","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"4706db46-0811-4652-8f59-1e0a1da84758","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8f1271bb-2cd9-4f39-9897-c15b239ee7ab","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"677e13a7-6f3e-449f-986c-2c3a26f8d54f","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"5e40f6dc-caec-49d7-a1d0-be65f06815ba","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2457f0e0-9e71-4860-a87d-065e0fb84f84","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"d5c67fd0-1145-482c-9113-97b492c44c18","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"a609a8fa-ab91-4c1d-a1c3-d209d0463303","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"b4a9eb15-94e5-48df-b218-a24138f0cf9c","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]}]
        
(Showing Draft Content)

在系统运行过程中执行自定义操作

功能概述

Wyn 是一个高度可定制的系统,客户可以在系统运行过程中执行一些可执行程序或脚本文件,以完成某些需求。

比如在Wyn 的所有服务启动后,自动注册 Wyn 许可证;在 Wyn 的所有服务启动后,自动刷新不可用的缓存;在 Wyn 的所有服务停止后备份数据库数据或清理临时文件等等。

接下来为您介绍具体的操作方法(集群版专用)

操作说明

执行阶段描述了系统生命周期中的某个阶段,一旦系统进入指定阶段,自定义动作就会被执行。

根据目前产品的设计,我们定义了四个阶段来执行自定义操作,它们分别是:BeforeStartingServicesAfterServicesStartedBeforeStoppingServicesAfterServicesStopped

  1. BeforeStartingServices ”阶段表示Wyn Monitor 服务已准备好启动所有服务。

  2. AfterServicesStarted ”阶段表示所有服务都已启动。

  3. BeforeStoppingServices ”阶段表示 Wyn Monitor 将在 Wyn Monitor 服务退出之前停止所有服务。

  4. AfterServicesStopped ”阶段表示Wyn Monitor 服务在退出前已经终止了所有服务。

各阶段流程图如下图所示:

e37f38cb-87e3-4d50-b780-69633841ac9e.png

具体操作

具体操作方式是将自定义操作添加到配置文件Wyn.conf (存在于目录wyn_installation_path/Monitor/conf/中),从而传递给 Wyn Monitor服务,Wyn Monitor 服务负责执行这些自定义操作。

包含自定义操作的配置文件示例如下所示:

<?xml version="1.0" encoding="utf-8"?>
<SystemConfig xmlns:sys="https://extendedxmlserializer.github.io/system" xmlns="clr-namespace:ConfigMigration.Configuration.V60;assembly=ConfigMigration">
  <Version>6.0</Version>
  <GlobalSettings>...</GlobalSettings>
  <Services>...</Services>
  <CustomActions>
    <CustomAction>
      <Name>testing-action</Name>
      <Description>An simple custom action for testing.</Description>
      <ExecutionStage>BeforeStartingServices/AfterServicesStarted/BeforeStoppingServices/AfterServicesStopped</ExecutionStage>
      <Process>dotnet</Process>
      <WorkingDirectory>/var/tmp/testing-action</WorkingDirectory>
      <Arguments>/opt/testing-action/testing-action.dll param1 param2 &quot;param 3&quot;</Arguments>
    </CustomAction>
  </CustomActions>
</SystemConfig>

是以<CustomActions>...</CustomActions> 为标记,其中可包含多个<CustomAction>...</CustomAction>。

示例

以下为两个简单的示例,每个配置文件包含 4 个自定义操作,用于在不同阶段将一些调试日志写入日志文件。请参考。

Wyn-windows.conf

Wyn-linux.conf