gpt4 book ai didi

azure - 如何将 Azure Worker 角色的 gcAllowVeryLargeObjects 设置为 true?

转载 作者:行者123 更新时间:2023-12-02 23:51:04 25 4
gpt4 key购买 nike

我无法理解如何为辅助角色设置 gcAllowVeryLargeObjectsruntime 参数。我在 app.config 中设置了这个婴儿车。但这不起作用。据我了解,我需要以某种方式在 wotker 主机的配置文件中配置它。

更新:基于答案的最终解决方案

服务定义.csdef

<WorkerRole name="XXX" vmsize="Standard_D4">
<Startup>
<Task commandLine="myStartup.cmd" executionContext="elevated" taskType="simple" >
<Environment>
<Variable name="yyy" value="yyy" />
</Environment>
</Task>
</Startup>

应将下一个文件作为始终复制本地的内容添加到工作项目中

启动.ps1

#Configure Server GC and Background GC settings 
Function ChangeGCSettings
{
param ([string]$filename,[bool]$enableServerGC,[bool]$enableBackgroundGC,[bool]$enableVeryLargeGC)

$xml = New-Object XML
if (Test-Path ($filename))
{
$xml.Load($filename)
}
else
{
#config file doesn't exist create a now one
[System.Xml.XmlDeclaration]$xmlDeclaration = $xml.CreateXmlDeclaration("1.0","utf-8",$null)
$xml.AppendChild($xmlDeclaration)
}

# Check if we already have a configuration section - if not create it
$conf = $xml.configuration
if ($conf -eq $null)
{
$conf = $xml.CreateElement("configuration")
$xml.AppendChild($conf)
}

# Check if we already have a runtime section - if not create it
$runtime = $conf.runtime
if ($runtime -eq $null)
{
#runtime element doesn't exist
$runtime = $xml.CreateElement("runtime")
$conf.AppendChild($runtime)
}

# configure ServerGC
$gcserver = $runtime.gcServer
if ($gcserver -eq $null)
{
$gcserver = $xml.CreateElement("gcServer")
$gcserver.SetAttribute("enabled",$enableServerGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower())
$runtime.AppendChild($gcserver);
}
else
{
$gcserver.enabled=$enableServerGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower()
}

# configure gcAllowVeryLargeObjectsruntime
$gcAllowVeryLargeObjects = $runtime.gcAllowVeryLargeObjects
if ($gcAllowVeryLargeObjects -eq $null)
{
$gcAllowVeryLargeObjects = $xml.CreateElement("gcAllowVeryLargeObjects")
$gcAllowVeryLargeObjects.SetAttribute("enabled",$enableVeryLargeGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower())
$runtime.AppendChild($gcAllowVeryLargeObjects);
}
else
{
$gcAllowVeryLargeObjects.enabled=$enableVeryLargeGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower()
}

# configure Background GC
# .NET 4.5 is required for Bacground Server GC
# since 4.5 is an in-place upgrade for .NET 4.0 the new Background Server GC mode is available
# even if you target 4.0 in your application as long as the .NET 4.5 runtime is installed (Windows Server 2012 or higher by default)
#
# See http://blogs.msdn.com/b/dotnet/archive/2012/07/20/the-net-framework-4-5-includes-new-garbage-collector-enhancements-for-client-and-server-apps.aspx

$gcConcurrent = $runtime.gcConcurrent
if ($gcConcurrent -eq $null)
{
$gcConcurrent = $xml.CreateElement("gcConcurrent")
$gcConcurrent.SetAttribute("enabled",$enableBackgroundGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower())
$runtime.AppendChild($gcConcurrent);
}
else
{
$gcConcurrent.enabled=$enableBackgroundGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower()
}
$xml.Save($filename)
}

# Enable Background Server GC
ChangeGCSettings "${env:RoleRoot}\base\x64\WaWorkerHost.exe.config" $true $true $true

myStartup.cmd

    REM   Attempt to set the execution policy by using PowerShell version 2.0 syntax.

REM PowerShell version 2.0 isn't available. Set the execution policy by using the PowerShell version 1.0 calling method.

PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog1.txt" 2>&1
PowerShell .\startup.ps1 >> "%TEMP%\StartupLog2.txt" 2>&1


REM If an error occurred, return the errorlevel.
EXIT /B %errorlevel%

最佳答案

查看http://blogs.msdn.com/b/cie/archive/2013/11/14/enable-server-gc-mode-for-your-worker-role.aspx它使用启动脚本以辅助角色启用服务器 GC。您应该能够轻松修改它以更改 gcAllowVeryLargeObjectsruntime 属性。

关于azure - 如何将 Azure Worker 角色的 gcAllowVeryLargeObjects 设置为 true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26677179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com