服務器配置熱更新
Keywords: 配置,熱更新
此功能能夠允許你在不重啟服務器的前提下更新服務器實例的配置。 (僅限1.6.5及其以上版本)
支持熱更新的服務器實例配置選項
SuperSocket 支持以下配置選項的熱更新:
* logCommand
* idleSessionTimeOut
* maxRequestLength
* logBasicSessionActivity
* logAllSocketException
SuperSocket 支持所有自定義配置屬性和自定義配置子節點的熱更新。
下面的代碼將演示如何讓你的自定義配置支持熱更新:
public class PushServer : AppServer
{
private int m_Interval;
protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
{
RegisterConfigHandler(config, "pushInterval", (value) =>
{
// the code in this scope will be executed automatically
// after the configuration attribute "pushInterval" is changed
var interval = 0;
int.TryParse(value, out interval);
if (interval <= 0)
interval = 60;// 60 seconds by default
m_Interval = interval * 1000;
return true;
});
return true;
}
/// Other code
}
你可以在QuickStart中的 PushServer 項目中找到此更能的完整示例代碼。
© 2018 - GetDocs.Net - Hosted by BuyVM
