Browse Source

Merge branch 'PR451'

tfb 11 years ago
parent
commit
a71ec03c49
3 changed files with 23 additions and 45 deletions
  1. 7 23
      servicestack/setup_iis.ps1
  2. 11 1
      servicestack/setup_nginx.py
  3. 5 21
      servicestack/setup_self.ps1

+ 7 - 23
servicestack/setup_iis.ps1

@@ -1,23 +1,5 @@
 param($action)
 
-$ErrorActionPreference = 'Stop'
-
-# From http://zduck.com/2012/powershell-batch-files-exit-codes/
-function Exec
-{
-    [CmdletBinding()]
-    param (
-        [Parameter(Position=0, Mandatory=1)]
-        [scriptblock]$Command,
-        [Parameter(Position=1, Mandatory=0)]
-        [string]$ErrorMessage = "Execution of command failed.`n$Command"
-    )
-    & $Command
-    if ($LastExitCode -ne 0) {
-        throw "Exec: $ErrorMessage"
-    }
-}
-
 $wwwroot = "C:\FrameworkBenchmarks\servicestack\www"
 $source = "C:\FrameworkBenchmarks\servicestack\src"
 $msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
@@ -25,15 +7,17 @@ $msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
 
 # Stop
 if (Get-WebSite -Name Benchmarks) { Remove-WebSite -Name Benchmarks }
-Get-ChildItem -Path $wwwroot -Recurse -ErrorAction 'SilentlyContinue' | Remove-Item -Force -Recurse -ErrorAction 'SilentlyContinue'; 
-Remove-Item -Force -Recurse $wwwroot -ErrorAction 'SilentlyContinue'
+Get-ChildItem -Path $wwwroot -Recurse -ErrorAction 'SilentlyContinue' | Remove-Item -Force -Recurse -ErrorAction 'SilentlyContinue' | Out-Null
+Remove-Item -Force -Recurse $wwwroot -ErrorAction 'SilentlyContinue' | Out-Null
 
 if ($action -eq 'start') {
     # Create a website in IIS
-    New-Item -Path $wwwroot -Type directory | Out-Null
+    New-Item -Path $wwwroot -Type Directory -ErrorAction 'SilentlyContinue' | Out-Null
     New-WebSite -Name Benchmarks -Port 8080 -PhysicalPath $wwwroot
     
     # Build the project
-    Exec { & $msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /t:Clean }
-    Exec { & $msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /p:DeployOnBuild=true /p:PublishProfile=IIS }
+    &$msbuild "$source\ServiceStackBenchmark.csproj" /t:RestorePackages
+    &$msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /t:Clean
+    &$msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /p:DeployOnBuild=true /p:PublishProfile=IIS
 }
+

+ 11 - 1
servicestack/setup_nginx.py

@@ -16,6 +16,7 @@ def start(args):
     # build
     subprocess.check_call("rm -rf bin obj", shell=True, cwd=app)
     subprocess.check_call("xbuild /p:Configuration=Release", shell=True, cwd=app)
+    subprocess.check_call("sudo chown -R $USER:$USER /usr/local/etc/mono", shell=True)
     
     # nginx
     workers = 'worker_processes ' + str(args.max_threads) + ';'
@@ -35,5 +36,14 @@ def stop():
   
   subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + root + "/nginx.conf -s stop", shell=True)
   subprocess.check_call("rm -f " + root + "/nginx.upstream.conf", shell=True)
-  subprocess.check_call("pkill -9 mono", shell=True)
+  #
+  # stop mono
+  #
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'mono-server' in line:
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 9)
   return 0
+

+ 5 - 21
servicestack/setup_self.ps1

@@ -1,32 +1,16 @@
 param($action)
 
-$ErrorActionPreference = 'Stop'
-
-# From http://zduck.com/2012/powershell-batch-files-exit-codes/
-function Exec
-{
-    [CmdletBinding()]
-    param (
-        [Parameter(Position=0, Mandatory=1)]
-        [scriptblock]$Command,
-        [Parameter(Position=1, Mandatory=0)]
-        [string]$ErrorMessage = "Execution of command failed.`n$Command"
-    )
-    & $Command
-    if ($LastExitCode -ne 0) {
-        throw "Exec: $ErrorMessage"
-    }
-}
-
 $source = "C:\FrameworkBenchmarks\servicestack\src"
 $msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
 
 # Stop
-Get-Process | Where-Object { $_.Name -ieq "servicestack" } | Stop-Process
+Stop-Process -Name servicestack -ErrorAction 'SilentlyContinue' | Out-Null
 
 if ($action -eq 'start') {
     # Build the project
-    Exec { & $msbuild "$source\ServiceStackBenchmark.sln" /p:DownloadNuGetExe=true /p:RequireRestoreConsent=false /p:Configuration=Release /p:Platform="x64" /t:Rebuild }
-        
+    &$msbuild "$source\ServiceStackBenchmark.sln" /t:RestorePackages
+    &$msbuild "$source\ServiceStackBenchmark.sln" /p:DownloadNuGetExe=true /p:RequireRestoreConsent=false /p:Configuration=Release /p:Platform=x64 /t:Rebuild
+    
     Start-Process "$source\SelfHost\bin\Release\ServiceStackBenchmark.SelfHost.exe http://*:8080"
 }
+