When updating an application, do you encounter the following cumbersome tasks: [site stop service-Update Service-Start Service]; because the file is occupied by the program, you must stop the program when updating the file, and start the program manually after the update is complete. KGlue is used to solve the preceding problems. Its main function is to use appDomain to load and run applications with each configuration; monitors application file changes and automatically detaches and restarts applications. simply put, after the file is directly replaced during application update, KGlue reloads the program.
Use Configuration
KGlue can be used to configure multiple applications. Applications can be stored in any directory accessible by KGlue. You only need to add the relevant application directory in the configuration file.
<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<ConfigSections>
<Section name = "appSection" type = "KGlue. AppSection, KGlue"/>
</ConfigSections>
<AppSection xmlns = "urn: KGlue">
<Items>
<Add name = "test" path = "test" args = "henry fan"/>
<Add name = "tcpserver" path = "tcp"/>
<Add name = "config" path = "config"/>
<Add name = "chatroom" path = "websocket_chatroom"/>
</Items>
</AppSection>
</Configuration>
The preceding configuration file describes the four applications. The path is the directory corresponding to the application. If the full path is not specified, it is the subdirectory under the KGlue running directory. The args parameter is required to start the application, it can be null. KGlue enables New AppDomains to run each configuration.
Application loading rules
KGlue supports loading DLL or code (cs, vb). Therefore, you only need to provide DLL or code files during release. because the application needs a rule definition to start, the corresponding class implementation KGlue. IAppAdapter can be used. KGlue traverses all DLL or code files in the configuration directory. After the domain is created, all IAppAdapter classes are instantiated and called.
Public class Class1: KGlue. IAppAdapter
{
Public void Start (string [] args)
{
Console. WriteLine (args. Length );
Foreach (string item in args)
{
Console. WriteLine (item );
}
}
Public string Name
{
Get {return "Class1 ";}
}
Public void Stop ()
{
}
}
The above is a simple application that outputs startup parameters. save the file to the corresponding directory (do not forget to put KGlue. dll Directory) and configure the KGlue configuration file.
<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<ConfigSections>
<Section name = "appSection" type = "KGlue. AppSection, KGlue"/>
</ConfigSections>
<AppSection xmlns = "urn: KGlue">
<Items>
<Add name = "test" path = "d: \ test" args = "henry fan"/>
</Items>
</AppSection>
</Configuration>