[]
        
(Showing Draft Content)

Customize Scripts in Wyn Monitoring Service (WMS)

Being a highly customizable application, Wyn Enterprise provides a wide range of customizable configuration items for different user needs and application scenarios. The configuration items known as Custom Actions in Wyn Enterprise, are executable programs or runnable scripts that you can use to accomplish your requirement goals in the application.

All services (including Analysis DB service, Scheduler service, Server services, etc.) in the Wyn Enterprise application are managed by the Wyn Monitoring Service (WMS). WMS defines four stages for executing services including Custom Actions as described below,

  1. BeforeStartingServices: indicates that the WMS is ready to start all services.

  2. AfterServicesStarted: indicates that all the services have been started.

  3. BeforeStoppingServices: indicates that the WMS is going to stop all the services before WMS exits.

  4. AfterServicesStopped: indicates that the WMS has terminated all the services before exiting.

    Note: Restarting the Wyn services will not trigger any changes in the system state. For example, modifying the System Configuration settings in Admin Portal will cause WMS to restart all the running services of Wyn Enterprise but this will not affect the current state of the system.

Customize Configuration Items

To customize the configuration items in Wyn Enterprise follow the below instructions. It is advised to take a backup copy of the Wyn.conf file before performing the following actions.

  1. Look for the Wyn.conf file in your system device where the Wyn Enterprise application is installed. It is generally located in - /Monitor/conf/} folder. Wyn Configuration File
  2. Open the Wyn.conf file in either Notepad or any other editing application and edit the configuration settings. Custom Actions will be created on making changes to the Wyn.conf file. Save the file at the same location as before.
  3. The Custom Actions added by you will be performed in the background when the system runs into a specific stage as defined in the Wyn.conf file.

Note: When the Custom Actions are executed, Wyn Enterprise application will wait for a maximum of 30 seconds for each custom action to exit the execution state. If the Custom Action takes more than 30 seconds to exit the state, Wyn system will continue to launch the app without impacting any other services.

Sample Wyn.conf file

Below is an example of a configuration file with Custom Actions,

    <?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>
        <IdentityServerUrl>http://localhost:51980</IdentityServerUrl>
      </GlobalSettings>
      <Services>
        <Server>
          <Urls>http://*:51980</Urls>
          <DataExtraction>
            <StorageType>Postgres</StorageType>
            <ConnectionString>Host=localhost;Port=5444;UserName=wyn-enterprise;Password=Wr8TGfe2r0;Database=wyndatacache;</ConnectionString>
          </DataExtraction>
          <Storage>
            <StorageType>Postgres</StorageType>
            <ConnectionString>Host=localhost;Port=5444;UserName=wyn-enterprise;Password=Wr8TGfe2r0;Database=wynserverdata;</ConnectionString>
          </Storage>
          <IdentityServer>
            <Provider>Server</Provider>
            <StorageType>Postgres</StorageType>
            <ConnectionString>Host=localhost;Port=5444;UserName=wyn-enterprise;Password=Wr8TGfe2r0;Database=wynis;</ConnectionString>
          </IdentityServer>
          <ServerCluster>
            <Host>127.0.0.1</Host>
            <Secret>a901eda9c66ca45e0b27f2bf519720f5c83c8f77033c8628c72f28cd8c45bbf2</Secret>
            <Port>51985</Port>
            <PrimaryNode>
              <Host>127.0.0.1</Host>
              <Port>51986</Port>
            </PrimaryNode>
          </ServerCluster>
          <Cors>
            <ExposedHeaders>
              <sys:string>Location</sys:string>
            </ExposedHeaders>
          </Cors>
        </Server>
        <ReportingWorker />
         <CotWorker />
        <DashboardWorker />
        <DataSourceService />
        <MemoryDBService />
        <SchedulerService />
        <AnalysisDBPrimaryNode />
        <AnalysisDBService />
      </Services>
      <Cluster>
        <Host>127.0.0.1</Host>
        <Secret>76cfd084cb077a2606c265311ee1b36d145dcaf1e944c42bb4db4c3e841ecfe7</Secret>
        <Port>51986</Port>
        <Role>primary</Role>
      </Cluster>
    <CustomActions>
      <CustomAction>
        <Name>action1</Name>
        <ExecutionStage>BeforeStartingServices</ExecutionStage>
        <Process>cmd.exe</Process>
        <Arguments>/c echo "%date% %time%" "before starting services..." &gt;&gt; D:\tmp\log.txt</Arguments>
      </CustomAction>
      <CustomAction>
        <Name>action2</Name>
        <ExecutionStage>AfterServicesStarted</ExecutionStage>
        <Process>cmd.exe</Process>
        <Arguments>/c echo "%date% %time%" "after services started..." &gt;&gt; D:\tmp\log.txt</Arguments>
      </CustomAction>
      <CustomAction>
        <Name>action3</Name>
        <ExecutionStage>BeforeStoppingServices</ExecutionStage>
        <Process>cmd.exe</Process>
        <Arguments>/c echo "%date% %time%" "before stopping services..." &gt;&gt; D:\tmp\log.txt</Arguments>
      </CustomAction>
      <CustomAction>
        <Name>action4</Name>
        <ExecutionStage>AfterServicesStopped</ExecutionStage>
        <Process>cmd.exe</Process>
        <Arguments>/c echo "%date% %time%" "after services stopped..." &gt;&gt; D:\tmp\log.txt</Arguments>
      </CustomAction>
    </CustomActions>
  </SystemConfig>

Model Definition of Custom Actions

  public class CustomAction : IConfigNode
  {
	  public string Name { get; set; }
	  public string Description { get; set; }
	  public string ExecutionStage { get; set; }
	  public string Process { get; set; }
	  public string WorkingDirectory { get; set; }
	  public string Arguments { get; set; }
  }

Interface Definition of Custom Actions

      /// <p>DOC-SUMMARY-TAG-OPEN</p>
     /// System states.
    /// <p>DOC-SUMMARY-TAG-CLOSE</p>
  public enum SystemStates
  {
	  /// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// System is initializing.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  SystemInitializing = 10,

  	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// Before starting all the services.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  BeforeStartingServices = 100,

  	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// After all the services started.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  AfterServicesStarted = 200,

  	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// Before stopping all the services.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  BeforeStoppingServices = 300,

  	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// After all the services stopped.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  AfterServicesStopped = 400,
  }
  /// <p>DOC-SUMMARY-TAG-OPEN</p>
  /// Interface of custom action.
  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
  public interface ICustomAction
  {
	  /// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// The name of the custom action.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  string Name { get; }

  	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// The description of the custom action.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  string Description { get; }

  	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	  /// Execute the custom action.
	  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
	  void Execute();
  }
  /// <p>DOC-SUMMARY-TAG-OPEN</p>
  /// Custom action registry.
  /// <p>DOC-SUMMARY-TAG-CLOSE</p>
  public interface IActionRegistry
  {
	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	/// Register a custom action.
	/// <p>DOC-SUMMARY-TAG-CLOSE</p>
	/// <param name="state"></param>
	/// <param name="action"></param>
	/// <returns></returns>
	IActionRegistry Register(SystemStates state, ICustomAction action);
	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	/// Unregister a custom action.
	/// <p>DOC-SUMMARY-TAG-CLOSE</p>
	/// <param name="state"></param>
	/// <param name="action"></param>
	/// <returns></returns>
	IActionRegistry Unregister(SystemStates state, ICustomAction action);
}
/// <p>DOC-SUMMARY-TAG-OPEN</p>
/// Interface of Finite State Machine
/// <p>DOC-SUMMARY-TAG-CLOSE</p>
public interface IFSM
{
	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	/// Get current state.
	/// <p>DOC-SUMMARY-TAG-CLOSE</p>
	SystemStates CurrentState { get; }
	/// <p>DOC-SUMMARY-TAG-OPEN</p>
	/// Change current state to a new state.
	/// <p>DOC-SUMMARY-TAG-CLOSE</p>
	/// <param name="newState"></param>
	void ChangeState(SystemStates newState);
}