Last week I looked at some simple PowerShell script to automate installing packages into Sitecore instances. Having spent a bit of time testing this process, I found a couple of useful tips for speeding it up:
url copied!
So it makes sense to fire of some simple requests to the Sitecore site before you try to install packages:
function Start-Sitecore(){
$siteName = Get-ConfigParam "InstanceName"
$url = "http://$siteName/"
Write-Host "Starting Sitecore..."
$result = Invoke-WebRequest -Uri $url -TimeoutSec 0
if($result.StatusCode -ne 200){
throw "Sitecore failed to start at url $url"
} else {
Write-Host "Public site started..."
}
$url = $url + "sitecore/"
$result = Invoke-WebRequest -Uri $url -TimeoutSec 0
if($result.StatusCode -ne 200){
throw "Sitecore UI failed to start at url $url"
} else {
Write-Host "Admin site started..."
}
}
This bit of code makes a request to the instance name (to load the public site) and then to the
/sitecore
folder to initialise the admin interface.
url copied!
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Indexing.UpdateInterval">
<patch:attribute name="value">00:00:00</patch:attribute>
</setting>
</settings>
</sitecore>
</configuration>
We can add a reference to a file containing this patch to the config for the install:
<config>
<params>
<param name="IndexPatchFile">.\files\StopLucene.config</param>
</params>
</config>
And then disabling indexing is as simple as copying that patch file to the right folder:
function Disable-Indexing(){
Write-Host "Disabling indexing..."
$siteName = Get-ConfigParam "InstanceName"
$sitecorePatchFolder = "C:\Inetpub\wwwroot\$($siteName)\Website\App_Config\Include"
$patchFilePath = Get-ConfigParam "IndexPatchFile"
Copy-Item $patchFilePath $sitecorePatchFolder
}
This function can be run immediately before starting Sitecore and then installing the package files. And once the packages are installed, the automatic indexing can be re-enabled by simply deleting the patch file again:
function Enable-Indexing(){
Write-Host "Re-enabling indexing..."
$siteName = Get-ConfigParam "InstanceName"
$sitecorePatchFolder = "C:\Inetpub\wwwroot\$($siteName)\Website\App_Config\Include"
$patchFilePath = Get-ConfigParam "IndexPatchFile"
$patchFile = (Split-Path -Path $patchFilePath -Leaf)
$file = Join-Path $sitecorePatchFolder $patchFile
Remove-Item $file
}
↑ Back to top