Skip to content
Browse files

Added MemcachedScaffolder described at http://blog.maartenballiauw.be…

  • Loading branch information...
1 parent 5e9e66d commit af127decd9f2808208e803106d8e5998f82325c9 @maartenba maartenba committed Oct 21, 2011
Showing with 631 additions and 0 deletions.
  1. BIN Memcached/MemcachedScaffolder.phar
  2. +1 −0 Memcached/MemcachedScaffolder/build.bat
  3. +185 −0 Memcached/MemcachedScaffolder/index.php
  4. +8 −0 Memcached/MemcachedScaffolder/resources/Common/bin/add-environment-variables.cmd
  5. +14 −0 Memcached/MemcachedScaffolder/resources/Common/bin/add-environment-variables.ps1
  6. +13 −0 Memcached/MemcachedScaffolder/resources/Common/bin/install-php-impl.cmd
  7. +19 −0 Memcached/MemcachedScaffolder/resources/Common/bin/install-php.cmd
  8. +37 −0 Memcached/MemcachedScaffolder/resources/Common/bin/install-php.ps1
  9. +7 −0 Memcached/MemcachedScaffolder/resources/Common/bin/memcached.cmd
  10. BIN Memcached/MemcachedScaffolder/resources/Common/bin/memcached.exe
  11. +37 −0 Memcached/MemcachedScaffolder/resources/Common/bin/memcached.ps1
  12. +7 −0 Memcached/MemcachedScaffolder/resources/Common/bin/monitor-environment.cmd
  13. +89 −0 Memcached/MemcachedScaffolder/resources/Common/bin/monitor-environment.ps1
  14. BIN Memcached/MemcachedScaffolder/resources/Common/bin/pthreadGC2.dll
  15. +35 −0 Memcached/MemcachedScaffolder/resources/Common/diagnostics.wadcfg
  16. BIN Memcached/MemcachedScaffolder/resources/Common/php/ext/php_memcache.dll
  17. +2 −0 Memcached/MemcachedScaffolder/resources/Common/php/ext/readme.txt
  18. +21 −0 Memcached/MemcachedScaffolder/resources/Common/php/php.ini
  19. BIN Memcached/MemcachedScaffolder/resources/Common/resources/WebPICmdLine/Microsoft.Web.Deployment.dll
  20. BIN ...emcachedScaffolder/resources/Common/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.UI.dll
  21. BIN ...d/MemcachedScaffolder/resources/Common/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.dll
  22. BIN Memcached/MemcachedScaffolder/resources/Common/resources/WebPICmdLine/WebpiCmdLine.exe
  23. +41 −0 Memcached/MemcachedScaffolder/resources/Common/resources/WebPICmdLine/license.rtf
  24. +20 −0 Memcached/MemcachedScaffolder/resources/CommonWeb/Web.config
  25. +9 −0 Memcached/MemcachedScaffolder/resources/CommonWeb/memcache.inc.php
  26. +1 −0 Memcached/MemcachedScaffolder/resources/CommonWorker/run.bat
  27. +7 −0 Memcached/MemcachedScaffolder/resources/CommonWorker/worker.php
  28. +6 −0 Memcached/MemcachedScaffolder/resources/ServiceConfiguration.Web.cscfg
  29. +6 −0 Memcached/MemcachedScaffolder/resources/ServiceConfiguration.Worker.cscfg
  30. +4 −0 Memcached/MemcachedScaffolder/resources/ServiceConfiguration.cscfg
  31. +30 −0 Memcached/MemcachedScaffolder/resources/ServiceDefinition.Web.csdef
  32. +27 −0 Memcached/MemcachedScaffolder/resources/ServiceDefinition.Worker.csdef
  33. +4 −0 Memcached/MemcachedScaffolder/resources/ServiceDefinition.csdef
  34. +1 −0 Memcached/README.markdown
View
BIN Memcached/MemcachedScaffolder.phar
Binary file not shown.
View
1 Memcached/MemcachedScaffolder/build.bat
@@ -0,0 +1 @@
+php ..\..\Scaffolder.php Build -in="./" -out="..\..\..\..\..\..\scaffolders\MemcachedScaffolder.phar"
View
185 Memcached/MemcachedScaffolder/index.php
@@ -0,0 +1,185 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of RealDolmen nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Microsoft
+ * @package Microsoft_WindowsAzure
+ * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license http://phpazure.codeplex.com/license
+ * @version $Id: SharedKeyCredentials.php 14561 2009-05-07 08:05:12Z unknown $
+ */
+
+
+/**
+ * @category Microsoft
+ * @package Microsoft_WindowsAzure_CommandLine
+ * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license http://phpazure.codeplex.com/license
+ *
+ * @command-handler MemcachedScaffolder
+ *
+ * @command-handler-description Windows Azure SDK for PHP default scaffolder.
+ * @command-handler-header Windows Azure SDK for PHP
+ * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @command-handler-footer
+ * @command-handler-footer The MemcachedScaffolder automatically installs PHP
+ * @command-handler-footer to the Windows Azure virtual machine. If a customized
+ * @command-handler-footer php.ini is required, add it in the /php folder after
+ * @command-handler-footer running the scaffolder.
+ * @command-handler-footer An added bonus is the availability of a preconfigured
+ * @command-handler-footer Memcached instance and client available by
+ * @command-handler-footer including 'memcache.inc.php' and using the $memcache
+ * @command-handler-footer variable.
+ */
+class MemcachedScaffolder
+ extends Microsoft_WindowsAzure_CommandLine_PackageScaffolder_PackageScaffolderAbstract
+{
+ /**
+ * Runs a scaffolder and creates a Windows Azure project structure which can be customized before packaging.
+ *
+ * @command-name Run
+ * @command-description Runs the scaffolder.
+ *
+ * @command-parameter-for $scaffolderFile Argv --Phar Required. The scaffolder Phar file path. This is injected automatically.
+ * @command-parameter-for $rootPath Argv|ConfigFile --OutputPath|-out Required. The path to create the Windows Azure project structure. This is injected automatically.
+ * @command-parameter-for $diagnosticsConnectionString Argv|ConfigFile|Env --DiagnosticsConnectionString|-d Optional. The diagnostics connection string. This defaults to development storage.
+ * @command-parameter-for $webRoleNames Argv|ConfigFile|Env --WebRoles|-web Optional. A comma-separated list of names for web roles to create when scaffolding. Set this value to an empty parameter to skip creating a web role.
+ * @command-parameter-for $workerRoleNames Argv|ConfigFile|Env --WorkerRoles|-workers Optional. A comma-separated list of names for worker roles to create when scaffolding.
+ */
+ public function runCommand($scaffolderFile, $rootPath, $webRoleNames = 'PhpOnAzure.Web', $workerRoleNames = '', $diagnosticsConnectionString = 'UseDevelopmentStorage=true')
+ {
+ // Load Phar
+ $phar = new Phar($scaffolderFile);
+
+ // Extract to disk
+ $this->log('Extracting resources...');
+ $this->createDirectory($rootPath);
+ $this->extractResources($phar, $rootPath);
+ $this->log('Extracted resources.');
+
+ // Configuration files
+ $serviceDefinitionIncludes = array();
+ $serviceConfigurationIncludes = array();
+
+ // Follow instructions listed in $webRoleNames and $workerRoleNames
+ $httpPort = 80;
+ $webRoles = explode(',', $webRoleNames);
+ foreach ($webRoles as $webRole) {
+ if ($webRole == '') continue;
+
+ $this->log('Creating web role "' . $webRole . '"...');
+
+ // Copy all files
+ $this->createDirectory($rootPath . '/' . $webRole);
+ $this->copyDirectory($rootPath . '/Common', $rootPath . '/' . $webRole, false);
+ $this->copyDirectory($rootPath . '/CommonWeb', $rootPath . '/' . $webRole, false);
+
+ // Configure role
+ $this->log(' Configuring web role "' . $webRole . '"...');
+
+ $serviceDefinitionFile = $rootPath . '/' . $webRole . '/ServiceDefinition.' . $webRole . '.csdef';
+ $serviceConfigurationFile = $rootPath . '/' . $webRole . '/ServiceConfiguration.' . $webRole . '.cscfg';
+ copy($rootPath . '/ServiceDefinition.Web.csdef', $serviceDefinitionFile);
+ copy($rootPath . '/ServiceConfiguration.Web.cscfg', $serviceConfigurationFile);
+
+ $this->applyTransforms($rootPath . '/' . $webRole, array(
+ 'DiagnosticsConnectionString' => $diagnosticsConnectionString,
+ 'RoleName' => $webRole,
+ 'HttpPort' => $httpPort++
+ ));
+ $serviceDefinitionIncludes[$webRole] = file_get_contents($serviceDefinitionFile);
+ $serviceConfigurationIncludes[$webRole] = file_get_contents($serviceConfigurationFile);
+ @unlink($serviceDefinitionFile);
+ @unlink($serviceConfigurationFile);
+
+ $this->log(' Configured web role "' . $webRole . '"...');
+
+ $this->log('Created web role "' . $webRole . '"...');
+ }
+
+ $workerRoles = explode(',', $workerRoleNames);
+ foreach ($workerRoles as $workerRole) {
+ if ($workerRole == '') continue;
+
+ $this->log('Creating worker role "' . $workerRole . '"...');
+
+ // Copy all files
+ $this->createDirectory($rootPath . '/' . $workerRole);
+ $this->copyDirectory($rootPath . '/Common', $rootPath . '/' . $workerRole, false);
+ $this->copyDirectory($rootPath . '/CommonWorker', $rootPath . '/' . $workerRole, false);
+
+ // Configure role
+ $this->log(' Configuring worker role "' . $workerRole . '"...');
+
+ $serviceDefinitionFile = $rootPath . '/' . $workerRole . '/ServiceDefinition.' . $workerRole . '.csdef';
+ $serviceConfigurationFile = $rootPath . '/' . $workerRole . '/ServiceConfiguration.' . $workerRole . '.cscfg';
+ copy($rootPath . '/ServiceDefinition.Worker.csdef', $serviceDefinitionFile);
+ copy($rootPath . '/ServiceConfiguration.Worker.cscfg', $serviceConfigurationFile);
+
+ $this->applyTransforms($rootPath . '/' . $workerRole, array(
+ 'DiagnosticsConnectionString' => $diagnosticsConnectionString,
+ 'RoleName' => $workerRole
+ ));
+ $serviceDefinitionIncludes[$workerRole] = file_get_contents($serviceDefinitionFile);
+ $serviceConfigurationIncludes[$workerRole] = file_get_contents($serviceConfigurationFile);
+ @unlink($serviceDefinitionFile);
+ @unlink($serviceConfigurationFile);
+
+ $this->log(' Configured worker role "' . $workerRole . '"...');
+
+ $this->log('Created worker role "' . $workerRole . '"...');
+ }
+
+ // Apply transforms
+ $this->log('Applying transforms...');
+ $this->applyTransforms($rootPath, array(
+ 'DiagnosticsConnectionString' => $diagnosticsConnectionString,
+ 'ServiceDefinition' => implode("\r\n", $serviceDefinitionIncludes),
+ 'ServiceConfiguration' => implode("\r\n", $serviceConfigurationIncludes)
+ ));
+ $this->log('Applied transforms.');
+
+ // Delete unnecessary files and folders
+ $this->log('Cleanup starting...');
+ $this->deleteDirectory($rootPath . '/Common');
+ $this->deleteDirectory($rootPath . '/CommonWeb');
+ $this->deleteDirectory($rootPath . '/CommonWorker');
+ @unlink($rootPath . '/ServiceConfiguration.Web.cscfg');
+ @unlink($rootPath . '/ServiceConfiguration.Worker.cscfg');
+ @unlink($rootPath . '/ServiceDefinition.Web.csdef');
+ @unlink($rootPath . '/ServiceDefinition.Worker.csdef');
+ $this->log('Cleanup finished.');
+
+ // Show "to do" message
+ $this->log('');
+ $this->log('Your Windows Azure project has been scaffolded.');
+ $this->log('In order to use Memcached in your application, do the following:');
+ $this->log(' - Add the memcache.inc.php as an include');
+ $this->log(' - The $memcache global variable will have a ready-to-use Memcache');
+ $this->log(' client for you to use. E.g. use $memcache->getVersion() in your code.');
+ $this->log('');
+ }
+}
View
8 Memcached/MemcachedScaffolder/resources/Common/bin/add-environment-variables.cmd
@@ -0,0 +1,8 @@
+@echo off
+cd "%~dp0"
+ECHO "Adding extra environment variables..." >> ..\startup-tasks-log.txt
+
+powershell.exe Set-ExecutionPolicy Unrestricted
+powershell.exe .\add-environment-variables.ps1 >> ..\startup-tasks-log.txt 2>>..\startup-tasks-error-log.txt
+
+ECHO "Added extra environment variables." >> ..\startup-tasks-log.txt
View
14 Memcached/MemcachedScaffolder/resources/Common/bin/add-environment-variables.ps1
@@ -0,0 +1,14 @@
+[Reflection.Assembly]::LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime")
+
+$rdRoleId = [Environment]::GetEnvironmentVariable("RdRoleId", "Machine")
+
+[Environment]::SetEnvironmentVariable("RdRoleId", [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id, "Machine")
+[Environment]::SetEnvironmentVariable("RoleName", [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Role.Name, "Machine")
+[Environment]::SetEnvironmentVariable("RoleInstanceID", [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id, "Machine")
+[Environment]::SetEnvironmentVariable("RoleDeploymentID", [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::DeploymentId, "Machine")
+
+if (![Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id.Contains("deployment")) {
+ if ($rdRoleId -ne [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id) {
+ Restart-Computer
+ }
+}
View
13 Memcached/MemcachedScaffolder/resources/Common/bin/install-php-impl.cmd
@@ -0,0 +1,13 @@
+@echo off
+cd "%~dp0"
+ECHO Starting PHP installation... >> ..\startup-tasks-log.txt
+
+md "%~dp0appdata"
+cd "%~dp0appdata"
+cd "%~dp0"
+
+reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f
+"..\resources\WebPICmdLine\webpicmdline" /Products:PHP53,SQLDriverPHP53IIS,PHPManager /AcceptEula >> ..\startup-tasks-log.txt 2>>..\startup-tasks-error-log.txt
+reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d %%USERPROFILE%%\AppData\Local /f
+
+ECHO Completed PHP installation. >> ..\startup-tasks-log.txt
View
19 Memcached/MemcachedScaffolder/resources/Common/bin/install-php.cmd
@@ -0,0 +1,19 @@
+@echo off
+cd "%~dp0"
+
+icacls %RoleRoot%\approot /grant "Everyone":F /T
+%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /-"[fullPath='%ProgramFiles(x86)%\PHP\v5.3\php-cgi.exe'].environmentVariables.[name='RoleRoot']" /commit:apphost
+%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%ProgramFiles(x86)%\PHP\v5.3\php-cgi.exe'].environmentVariables.[name='RoleRoot',value='%RoleRoot%']" /commit:apphost
+
+REM This script will only execute on production Windows Azure.
+if "%EMULATED%"=="true" goto :EOF
+
+ECHO Installing PHP runtime... >> ..\startup-tasks-log.txt
+
+powershell.exe Set-ExecutionPolicy Unrestricted
+powershell.exe .\install-php.ps1
+
+icacls %RoleRoot%\approot /grant "Everyone":F /T
+%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%ProgramFiles(x86)%\PHP\v5.3\php-cgi.exe'].environmentVariables.[name='PATH',value='%PATH%;%RoleRoot%\base\x86']" /commit:apphost
+
+ECHO Installed PHP runtime. >> ..\startup-tasks-log.txt
View
37 Memcached/MemcachedScaffolder/resources/Common/bin/install-php.ps1
@@ -0,0 +1,37 @@
+[Reflection.Assembly]::LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime")
+
+.\install-php-impl.cmd
+
+# Get PHP installation details
+Add-PsSnapin PHPManagerSnapin
+$phpConfiguration = Get-PHPConfiguration
+$phpExecutable = Get-ChildItem $phpConfiguration.ScriptProcessor
+$phpExtensionsPath = $phpExecutable.DirectoryName + "\ext"
+$phpIniFile = $phpConfiguration.PHPIniFilePath
+
+# Get PHP installation override details
+$myExtensionsPath = "..\php\ext"
+$myExtensions = Get-ChildItem $myExtensionsPath | where {$_.Name.ToLower().EndsWith(".dll")}
+$myPhpIniFile = "..\php\php.ini"
+
+# Append PHP.ini directives
+if ((Test-Path $myPhpIniFile) -eq 'True') {
+ $additionalPhpIniDirectives = Get-Content $myPhpIniFile
+ $additionalPhpIniDirectives = $additionalPhpIniDirectives.Replace("%EXT%", $phpExtensionsPath)
+
+ Add-Content $phpIniFile "`r`n"
+ Add-Content $phpIniFile $additionalPhpIniDirectives
+}
+
+# Copy and register extensions
+if ($myExtensions -ne $null) {
+ foreach ($myExtension in $myExtensions) {
+ Copy-Item $myExtension.FullName $phpExtensionsPath
+ Set-PHPExtension -Name $myExtension.Name -Status enabled
+ }
+}
+
+# Add PHP executable to PATH
+if (![Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id.Contains("deployment")) {
+ [Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'Machine') + ";" + $phpExecutable.DirectoryName, 'Machine')
+}
View
7 Memcached/MemcachedScaffolder/resources/Common/bin/memcached.cmd
@@ -0,0 +1,7 @@
+@echo off
+cd "%~dp0"
+
+icacls %RoleRoot%\approot /grant "Everyone":F /T
+
+powershell.exe Set-ExecutionPolicy Unrestricted
+powershell.exe .\memcached.ps1
View
BIN Memcached/MemcachedScaffolder/resources/Common/bin/memcached.exe
Binary file not shown.
View
37 Memcached/MemcachedScaffolder/resources/Common/bin/memcached.ps1
@@ -0,0 +1,37 @@
+[Reflection.Assembly]::LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime")
+
+# Dump all memcached endpoints to ../memcached-servers.php
+$memcached = "<?php`r`n"
+$memcached += "`$memcachedServers = array("
+
+$currentRolename = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Role.Name
+$roles = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::Roles
+foreach ($role in $roles.Keys | sort-object) {
+ if ($role -eq $currentRolename) {
+ $instances = $roles[$role].Instances
+ for ($i = 0; $i -lt $instances.Count; $i++) {
+ $endpoints = $instances[$i].InstanceEndpoints
+ foreach ($endpoint in $endpoints.Keys | sort-object) {
+ if ($endpoint -eq "MemcachedEndpoint") {
+ $memcached += "array(`""
+ $memcached += $endpoints[$endpoint].IPEndpoint.Address
+ $memcached += "`" ,"
+ $memcached += $endpoints[$endpoint].IPEndpoint.Port
+ $memcached += "), "
+ }
+
+
+ }
+ }
+ }
+}
+
+$memcached += ");"
+
+Write-Output $memcached | Out-File -Encoding Ascii ../memcached-servers.php
+
+# Start memcached. To infinity and beyond!
+while (1) {
+ $p = [diagnostics.process]::Start("memcached.exe", "-m 64 -p " + [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.InstanceEndpoints["MemcachedEndpoint"].IPEndpoint.Port)
+ $p.WaitForExit()
+}
View
7 Memcached/MemcachedScaffolder/resources/Common/bin/monitor-environment.cmd
@@ -0,0 +1,7 @@
+@echo off
+cd "%~dp0"
+
+icacls %RoleRoot%\approot /grant "Everyone":F /T
+
+powershell.exe Set-ExecutionPolicy Unrestricted
+powershell.exe .\monitor-environment.ps1
View
89 Memcached/MemcachedScaffolder/resources/Common/bin/monitor-environment.ps1
@@ -0,0 +1,89 @@
+[Reflection.Assembly]::LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime")
+
+# To infinity and beyond!
+
+while(1) {
+
+##########################################################
+# Monitor environment to XML file
+##########################################################
+
+# Build some XML that may be useful to non-Microsoft languages running on Windows Azure
+$reXml = "<?xml version=`"1.0`" encoding=`"UTF-8`" ?>`r`n"
+$reXml += [System.String]::Format("<RoleEnvironment deploymentId=`"{0}`" isAvailable=`"{1}`" isEmulated=`"{2}`">`r`n", [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::DeploymentId, [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::IsAvailable, [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::IsEmulated)
+
+$reXml += [System.String]::Format(" <CurrentRoleInstance id=`"{0}`" roleName=`"{1}`" updateDomain=`"{2}`" faultDomain=`"{2}`">`r`n", [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id, [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Role.Name, [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.UpdateDomain, [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.FaultDomain)
+$reXml += " <Endpoints>`r`n"
+$endpoints = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.InstanceEndpoints
+foreach ($endpoint in $endpoints.Keys) {
+ $reXml += [System.String]::Format(" <Endpoint id=`"{0}`" protocol=`"{1}`" address=`"{2}`" port=`"{3}`" />`r`n", $endpoint, $endpoints[$endpoint].Protocol, $endpoints[$endpoint].IPEndpoint.Address, $endpoints[$endpoint].IPEndpoint.Port)
+}
+$reXml += " </Endpoints>`r`n"
+$reXml += " </CurrentRoleInstance>`r`n"
+
+$reXml += " <Roles>`r`n"
+$roles = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::Roles
+foreach ($role in $roles.Keys) {
+ $reXml += [System.String]::Format(" <Role name=`"{0}`">`r`n", $role)
+ $reXml += " <Instances>`r`n"
+ $instances = $roles[$role].Instances
+ for ($i = 0; $i -lt $instances.Count; $i++) {
+ $reXml += [System.String]::Format(" <RoleInstance id=`"{0}`" roleName=`"{1}`" updateDomain=`"{2}`" faultDomain=`"{2}`">`r`n", $instances[$i].Id, $instances[$i].Role.Name, $instances[$i].UpdateDomain, $instances[$i].FaultDomain)
+ $reXml += " <Endpoints>`r`n"
+ $endpoints = $instances[$i].InstanceEndpoints
+ foreach ($endpoint in $endpoints.Keys) {
+ $reXml += [System.String]::Format(" <Endpoint id=`"{0}`" protocol=`"{1}`" address=`"{2}`" port=`"{3}`" />`r`n", $endpoint, $endpoints[$endpoint].Protocol, $endpoints[$endpoint].IPEndpoint.Address, $endpoints[$endpoint].IPEndpoint.Port)
+ }
+ $reXml += " </Endpoints>`r`n"
+ $reXml += " </RoleInstance>`r`n"
+ }
+ $reXml += " </Instances>`r`n"
+ $reXml += " </Role>`r`n"
+}
+$reXml += " </Roles>`r`n"
+
+$reXml += "</RoleEnvironment>`r`n"
+
+
+Write-Output $reXml | Out-File -Encoding Ascii ../monitor-environment.xml
+
+
+##########################################################
+# Create memcached include file for PHP
+##########################################################
+
+# Dump all memcached endpoints to ../memcached-servers.php
+$memcached = "<?php`r`n"
+$memcached += "`$memcachedServers = array("
+
+$currentRolename = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Role.Name
+$roles = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::Roles
+foreach ($role in $roles.Keys | sort-object) {
+ if ($role -eq $currentRolename) {
+ $instances = $roles[$role].Instances
+ for ($i = 0; $i -lt $instances.Count; $i++) {
+ $endpoints = $instances[$i].InstanceEndpoints
+ foreach ($endpoint in $endpoints.Keys | sort-object) {
+ if ($endpoint -eq "MemcachedEndpoint") {
+ $memcached += "array(`""
+ $memcached += $endpoints[$endpoint].IPEndpoint.Address
+ $memcached += "`" ,"
+ $memcached += $endpoints[$endpoint].IPEndpoint.Port
+ $memcached += "), "
+ }
+
+
+ }
+ }
+ }
+}
+
+$memcached += ");"
+
+Write-Output $memcached | Out-File -Encoding Ascii ../memcached-servers.php
+
+
+
+# Restart the loop in 1 minute
+Start-Sleep -Seconds 60
+}
View
BIN Memcached/MemcachedScaffolder/resources/Common/bin/pthreadGC2.dll
Binary file not shown.
View
35 Memcached/MemcachedScaffolder/resources/Common/diagnostics.wadcfg
@@ -0,0 +1,35 @@
+<DiagnosticMonitorConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration" configurationChangePollInterval="PT1M" overallQuotaInMB="4096">
+ <DiagnosticInfrastructureLogs bufferQuotaInMB="10"
+ scheduledTransferLogLevelFilter="Error"
+ scheduledTransferPeriod="PT1M" />
+
+ <Logs bufferQuotaInMB="0"
+ scheduledTransferLogLevelFilter="Verbose"
+ scheduledTransferPeriod="PT1M" />
+
+ <Directories bufferQuotaInMB="0"
+ scheduledTransferPeriod="PT5M">
+
+ <!-- These three elements specify the special directories
+ that are set up for the log types -->
+ <CrashDumps container="wad-crash-dumps" directoryQuotaInMB="256" />
+ <FailedRequestLogs container="wad-frq" directoryQuotaInMB="256" />
+ <IISLogs container="wad-iis" directoryQuotaInMB="256" />
+ </Directories>
+
+ <PerformanceCounters bufferQuotaInMB="0" scheduledTransferPeriod="PT1M">
+ <!-- The counter specifier is in the same format as the imperative
+ diagnostics configuration API -->
+ <PerformanceCounterConfiguration
+ counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT5M" />
+ <PerformanceCounterConfiguration
+ counterSpecifier="\Memory\Available Mbytes" sampleRate="PT5M" />
+ </PerformanceCounters>
+ <WindowsEventLog bufferQuotaInMB="0"
+ scheduledTransferLogLevelFilter="Verbose"
+ scheduledTransferPeriod="PT5M">
+ <!-- The event log name is in the same format as the imperative
+ diagnostics configuration API -->
+ <DataSource name="System!*" />
+ </WindowsEventLog>
+</DiagnosticMonitorConfiguration>
View
BIN Memcached/MemcachedScaffolder/resources/Common/php/ext/php_memcache.dll
Binary file not shown.
View
2 Memcached/MemcachedScaffolder/resources/Common/php/ext/readme.txt
@@ -0,0 +1,2 @@
+Extensons in this folder will be enabled
+on the Windows Azure role instance.
View
21 Memcached/MemcachedScaffolder/resources/Common/php/php.ini
@@ -0,0 +1,21 @@
+[PhpAzureChanges]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; This file will be appended to the PHP.ini file located
+; on the Windows Azure role instance.
+;
+; It can be used to:
+; - Enable extensions (note that extensions copied to
+; the ext folder are enabled automatically)
+; - Override PHP settings
+; - ...
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+; Change memory limit (example)
+; memory_limit = 1024M
+
+; Enable an extension (example)
+; extension=php_curl.dll
+
+; %EXT% will be replaced by the absolute path to PHP's
+; extension folder.
+; zend_extension=%EXT%
View
BIN .../MemcachedScaffolder/resources/Common/resources/WebPICmdLine/Microsoft.Web.Deployment.dll
Binary file not shown.
View
BIN ...Scaffolder/resources/Common/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.UI.dll
Binary file not shown.
View
BIN ...hedScaffolder/resources/Common/resources/WebPICmdLine/Microsoft.Web.PlatformInstaller.dll
Binary file not shown.
View
BIN Memcached/MemcachedScaffolder/resources/Common/resources/WebPICmdLine/WebpiCmdLine.exe
Binary file not shown.
View
41 Memcached/MemcachedScaffolder/resources/Common/resources/WebPICmdLine/license.rtf
@@ -0,0 +1,41 @@
+{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Tahoma;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\froman\fprq2\fcharset2 Symbol;}}
+{\colortbl ;\red0\green0\blue0;\red0\green0\blue255;}
+{\stylesheet{ Normal;}{\s1 heading 1;}{\s2 heading 2;}}
+{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\nowidctlpar\sb120\sa120\b\f0\fs20 MICROSOFT SOFTWARE LICENSE TERMS\par
+\pard\brdrb\brdrs\brdrw10\brsp20 \nowidctlpar\sb120\sa120 MICROSOFT WEB PLATFORM INSTALLER 3.0\f1\par
+\pard\nowidctlpar\sb120\sa120\b0\f0 These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft\par
+\pard\nowidctlpar\fi-360\li360\sb120\sa120\tx360\f2\'b7\tab\f0 updates,\par
+\pard\nowidctlpar\fi-360\li360\sb120\sa120\f2\'b7\tab\f0 supplements,\par
+\f2\'b7\tab\f0 Internet-based services, and\par
+\f2\'b7\tab\f0 support services\par
+\pard\nowidctlpar\sb120\sa120 for this software, unless other terms accompany those items. If so, those terms apply.\par
+\b By using the software, you accept these terms. If you do not accept them, do not use the software.\par
+\pard\brdrt\brdrs\brdrw10\brsp20 \nowidctlpar\sb120\sa120 If you comply with these license terms, you have the rights below.\par
+\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\tx360 1.\tab INSTALLATION AND USE RIGHTS. \b0 You may install and use any number of copies of the software on your devices.\f1\par
+\pard\s1\fi-357\li357\sb120\sa120\tx360\b\caps\f0 2.\tab\fs19 Third Party Programs\caps0\f1 .\b0\f0\fs20 T\kerning36 his software enables you to obtain software applications from other sources. Those applications are offered and distributed by third parties under their own license terms. Microsoft is not developing, distributing or licensing those applications to you, but instead, as a convenience, enables you to use this software to obtain those applications directly from the application providers. By using the software, you acknowledge and agree that you are obtaining the applications directly from the third party providers and under separate license terms, and that it is your responsibility to locate, understand and comply with those license terms.\fs19 Microsoft grants you no license rights for third-party software or applications that is obtained using this software. \kerning0 \b\f1\par
+\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\tx360\f0\fs20 3.\tab INTERNET-BASED SERVICES. \b0 Microsoft provides Internet-based services with the software. It may change or cancel them at any time. \cf1 The software contains product information that is updated by means of a feed online from Microsoft.\cf0\f1\par
+\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\b\f0 4.\tab SCOPE OF LICENSE.\b0 The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not\par
+\pard\nowidctlpar\fi-363\li720\sb120\sa120\tx720\f2\'b7\tab\f0 work around any technical limitations in the software;\par
+\pard\nowidctlpar\fi-363\li720\sb120\sa120\f2\'b7\tab\f0 reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;\par
+\f2\'b7\tab\f0 make more copies of the software than specified in this agreement or allowed by applicable law, despite this limitation;\par
+\f2\'b7\tab\f0 publish the software for others to copy;\par
+\f2\'b7\tab\f0 rent, lease or lend the software; or\par
+\f2\'b7\tab\f0 transfer the software or this agreement to any third party;\par
+\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\tx360\b 5.\tab BACKUP COPY.\b0 You may make one backup copy of the software. You may use it only to reinstall the software.\par
+\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\b 6.\tab DOCUMENTATION.\b0 Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes.\par
+\b 7.\tab TRANSFER TO ANOTHER DEVICE.\b0 You may uninstall the software and install it on another device for your use. You may not do so to share this license between devices.\par
+\b 8.\tab EXPORT RESTRICTIONS.\b0 The software is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the software. These laws include restrictions on destinations, end users and end use. For additional information, see {\field{\*\fldinst{HYPERLINK "www.microsoft.com/exporting"}}{\fldrslt{\ul\cf2 www.microsoft.com/exporting}}}\f1\fs20 .\ul\par
+\ulnone\b\f0 9.\tab SUPPORT SERVICES. \b0 Because this software is \ldblquote as is,\rdblquote we may not provide support services for it.\par
+\b 10.\tab ENTIRE AGREEMENT.\b0 This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services.\par
+\pard\nowidctlpar\s1\fi-360\li360\sb120\sa120\tx360\b 11.\tab APPLICABLE LAW.\par
+\pard\nowidctlpar\s2\fi-363\li720\sb120\sa120\tx720 a.\tab United States.\b0 If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort.\par
+\pard\nowidctlpar\s2\fi-363\li720\sb120\sa120\b b.\tab Outside the United States.\b0 If you acquired the software in any other country, the laws of that country apply.\par
+\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\tx360\b 12.\tab LEGAL EFFECT.\b0 This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.\par
+\pard\s1\fi-357\li357\sb120\sa120\tx360\b 13.\tab DISCLAIMER OF WARRANTY. The software is licensed \ldblquote as-is.\rdblquote You bear the risk of using it. Microsoft gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this agreement cannot change. To the extent permitted under your local laws, Microsoft excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement.\par
+\pard\s1\fi-357\li357\sb120\sa120 14.\tab LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. You can recover from Microsoft and its suppliers only direct damages up to U.S. $5.00. You cannot recover any other damages, including consequential, lost profits, special, indirect or incidental damages.\par
+\pard\nowidctlpar\li357\sb120\sa120\b0 This limitation applies to\par
+\pard\nowidctlpar\fi-363\li720\sb120\sa120\tx720\f2\'b7\tab\f0 anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and\par
+\pard\nowidctlpar\fi-363\li720\sb120\sa120\f2\'b7\tab\f0 claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.\par
+\pard\sb120\sa120 It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages\f1 .\fs19\par
+}
+
View
20 Memcached/MemcachedScaffolder/resources/CommonWeb/Web.config
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<configuration>
+ <system.diagnostics>
+ <trace>
+ <listeners>
+ <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
+ <filter type="" />
+ </add>
+ </listeners>
+ </trace>
+ </system.diagnostics>
+ <system.webServer>
+ <defaultDocument>
+ <files>
+ <clear />
+ <add value="index.php" />
+ </files>
+ </defaultDocument>
+ </system.webServer>
+</configuration>
View
9 Memcached/MemcachedScaffolder/resources/CommonWeb/memcache.inc.php
@@ -0,0 +1,9 @@
+<?php
+require_once $_SERVER["RoleRoot"] . '\\approot\\memcached-servers.php';
+$memcache = new Memcache();
+foreach ($memcachedServers as $memcachedServer) {
+ if (strpos($memcachedServer[0], '127.') !== false) {
+ $memcachedServer[0] = 'localhost';
+ }
+ $memcache->addServer($memcachedServer[0], $memcachedServer[1]);
+}
View
1 Memcached/MemcachedScaffolder/resources/CommonWorker/run.bat
@@ -0,0 +1 @@
+php worker.php
View
7 Memcached/MemcachedScaffolder/resources/CommonWorker/worker.php
@@ -0,0 +1,7 @@
+<?php
+while(true) {
+ // Your worker role code goes in here.
+ //
+ // Note that whenever the control loop ends or breaks,
+ // the worker role instance will automatically restart.
+}
View
6 Memcached/MemcachedScaffolder/resources/ServiceConfiguration.Web.cscfg
@@ -0,0 +1,6 @@
+ <Role name="$RoleName$">
+ <Instances count="1" />
+ <ConfigurationSettings>
+ <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="$DiagnosticsConnectionString$"/>
+ </ConfigurationSettings>
+ </Role>
View
6 Memcached/MemcachedScaffolder/resources/ServiceConfiguration.Worker.cscfg
@@ -0,0 +1,6 @@
+ <Role name="$RoleName$">
+ <Instances count="1" />
+ <ConfigurationSettings>
+ <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="$DiagnosticsConnectionString$"/>
+ </ConfigurationSettings>
+ </Role>
View
4 Memcached/MemcachedScaffolder/resources/ServiceConfiguration.cscfg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ServiceConfiguration serviceName="PhpOnAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*">
+$ServiceConfiguration$
+</ServiceConfiguration>
View
30 Memcached/MemcachedScaffolder/resources/ServiceDefinition.Web.csdef
@@ -0,0 +1,30 @@
+ <WebRole name="$RoleName$" enableNativeCodeExecution="true">
+ <Sites>
+ <Site name="Web" physicalDirectory="./$RoleName$">
+ <Bindings>
+ <Binding name="Endpoint1" endpointName="HttpEndpoint" />
+ </Bindings>
+ </Site>
+ </Sites>
+ <Startup>
+ <Task commandLine="add-environment-variables.cmd" executionContext="elevated" taskType="simple" />
+ <Task commandLine="install-php.cmd" executionContext="elevated" taskType="simple">
+ <Environment>
+ <Variable name="EMULATED">
+ <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
+ </Variable>
+ </Environment>
+ </Task>
+ <Task commandLine="memcached.cmd" executionContext="elevated" taskType="background" />
+ <Task commandLine="monitor-environment.cmd" executionContext="elevated" taskType="background" />
+ </Startup>
+ <Endpoints>
+ <InputEndpoint name="HttpEndpoint" protocol="http" port="$HttpPort$" />
+ <InternalEndpoint name="MemcachedEndpoint" protocol="tcp" />
+ </Endpoints>
+ <Imports>
+ <Import moduleName="Diagnostics"/>
+ </Imports>
+ <ConfigurationSettings>
+ </ConfigurationSettings>
+ </WebRole>
View
27 Memcached/MemcachedScaffolder/resources/ServiceDefinition.Worker.csdef
@@ -0,0 +1,27 @@
+ <WorkerRole name="$RoleName$">
+ <Runtime executionContext="elevated">
+ <EntryPoint>
+ <ProgramEntryPoint commandLine="run.bat" setReadyOnProcessStart="true" />
+ </EntryPoint>
+ </Runtime>
+ <Startup>
+ <Task commandLine="bin\add-environment-variables.cmd" executionContext="elevated" taskType="simple" />
+ <Task commandLine="bin\install-php.cmd" executionContext="elevated" taskType="simple">
+ <Environment>
+ <Variable name="EMULATED">
+ <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
+ </Variable>
+ </Environment>
+ </Task>
+ <Task commandLine="memcached.cmd" executionContext="elevated" taskType="background" />
+ <Task commandLine="bin\monitor-environment.cmd" executionContext="elevated" taskType="background" />
+ </Startup>
+ <Endpoints>
+ <InternalEndpoint name="MemcachedEndpoint" protocol="tcp" />
+ </Endpoints>
+ <Imports>
+ <Import moduleName="Diagnostics"/>
+ </Imports>
+ <ConfigurationSettings>
+ </ConfigurationSettings>
+ </WorkerRole>
View
4 Memcached/MemcachedScaffolder/resources/ServiceDefinition.csdef
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ServiceDefinition name="PhpOnAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
+$ServiceDefinition$
+</ServiceDefinition>
View
1 Memcached/README.markdown
@@ -0,0 +1 @@
+See http://blog.maartenballiauw.be/post/2011/10/21/Running-Memcached-on-Windows-Azure-for-PHP.aspx for usage instructions

0 comments on commit af127de

Please sign in to comment.
Something went wrong with that request. Please try again.