فهرست منبع

Peachpie update .NET runtime, Server GC (#3793)

* Peachpie update .NET runtime, Server GC

* Add Content-Length
Ben Adams 7 سال پیش
والد
کامیت
077a8a3a80

+ 38 - 0
frameworks/PHP/peachpie/.gitignore

@@ -0,0 +1,38 @@
+[Oo]bj/
+[Bb]in/
+[Oo]ut/
+TestResults/
+.nuget/
+*.sln.ide/
+_ReSharper.*/
+.idea/
+packages/
+artifacts/
+PublishProfiles/
+.vs/
+*.user
+*.suo
+*.cache
+*.docstates
+_ReSharper.*
+nuget.exe
+*net45.csproj
+*net451.csproj
+*k10.csproj
+*.psess
+*.vsp
+*.pidb
+*.userprefs
+*DS_Store
+*.ncrunchsolution
+*.*sdf
+*.ipch
+*.swp
+*~
+.build/
+.testPublish/
+launchSettings.json
+BenchmarkDotNet.Artifacts/
+BDN.Generated/
+binaries/
+global.json

+ 8 - 3
frameworks/PHP/peachpie/Server/Program.cs

@@ -1,4 +1,5 @@
 using System;
 using System;
+using System.Threading;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.DependencyInjection;
@@ -10,6 +11,10 @@ namespace MyWebsite.Server
     {
     {
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
+            ThreadPool.GetMinThreads(out int workerThread, out int completionThread);
+            // Double ThreadPool for non-async calls
+            ThreadPool.SetMinThreads(workerThread * 2, completionThread);
+
             var host = new WebHostBuilder()
             var host = new WebHostBuilder()
                 .UseKestrel()
                 .UseKestrel()
                 .UseUrls("http://*:8080/")
                 .UseUrls("http://*:8080/")
@@ -24,10 +29,10 @@ namespace MyWebsite.Server
     {
     {
         public void Configure(IApplicationBuilder app)
         public void Configure(IApplicationBuilder app)
         {
         {
-            app.UseResponseBuffering();
+            // app.UseResponseBuffering();
             app.UsePhp(new PhpRequestOptions(scriptAssemblyName: "Website"));
             app.UsePhp(new PhpRequestOptions(scriptAssemblyName: "Website"));
-            app.UseDefaultFiles();
-            app.UseStaticFiles();
+            // app.UseDefaultFiles();
+            // app.UseStaticFiles();
         }
         }
     }
     }
 }
 }

+ 6 - 6
frameworks/PHP/peachpie/Server/Server.csproj

@@ -1,15 +1,15 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk.Web">
 
 
   <PropertyGroup>
   <PropertyGroup>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
     <OutputType>Exe</OutputType>
     <OutputType>Exe</OutputType>
-    <TargetFramework>netcoreapp2.0</TargetFramework>
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.1" />
-    <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.0.1" />
-    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
-    <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
+    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.0-rc1-final" />
+    <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.0-rc1-final" />
+    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.0-rc1-final" />
+    <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.0-rc1-final" />
     <PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
     <PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
     <PackageReference Include="Peachpie.NETCore.Web" Version="0.9.0-CI00897" />
     <PackageReference Include="Peachpie.NETCore.Web" Version="0.9.0-CI00897" />
   </ItemGroup>
   </ItemGroup>

+ 6 - 2
frameworks/PHP/peachpie/Website/dbraw.php

@@ -41,10 +41,14 @@ function dbraw() {
   // Use the PHP standard JSON encoder.
   // Use the PHP standard JSON encoder.
   // http://www.php.net/manual/en/function.json-encode.php
   // http://www.php.net/manual/en/function.json-encode.php
   if ($is_multi) {
   if ($is_multi) {
-    echo json_encode($arr);
+    $output = json_encode($arr);
   } else {
   } else {
-    echo json_encode($arr[0]);
+    $output = json_encode($arr[0]);
   }
   }
+  // Set content length
+  header("Content-Length: {strlen($output)}");
+
+  echo $output;
 }
 }
 
 
 dbraw();
 dbraw();

+ 6 - 1
frameworks/PHP/peachpie/Website/json.php

@@ -14,7 +14,12 @@ function json() {
 
 
   // Use the PHP standard JSON encoder.
   // Use the PHP standard JSON encoder.
   // http://www.php.net/manual/en/function.json-encode.php
   // http://www.php.net/manual/en/function.json-encode.php
-  echo json_encode($arr);
+  $output =  json_encode($arr);
+
+  // Set content length
+  header("Content-Length: {strlen($output)}");
+
+  echo $output;
 }
 }
 
 
 json();
 json();

+ 2 - 0
frameworks/PHP/peachpie/Website/plaintext.php

@@ -5,6 +5,8 @@
 
 
 // Set content type
 // Set content type
 header("Content-type: text/plain");
 header("Content-type: text/plain");
+// Set content length
+header("Content-Length: 13");
 
 
 ?>
 ?>
 Hello, World!
 Hello, World!

+ 5 - 1
frameworks/PHP/peachpie/Website/updateraw.php

@@ -46,7 +46,11 @@ function updateraw() {
 
 
   // Use the PHP standard JSON encoder.
   // Use the PHP standard JSON encoder.
   // http://www.php.net/manual/en/function.json-encode.php
   // http://www.php.net/manual/en/function.json-encode.php
-  echo json_encode($arr);
+  $output = json_encode($arr);
+  // Set content length
+  header("Content-Length: {strlen($output)}");
+
+  echo $output;
 }
 }
 
 
 updateraw();
 updateraw();

+ 1 - 1
frameworks/PHP/peachpie/benchmark_config.json

@@ -17,7 +17,7 @@
       "flavor": "PHP7",
       "flavor": "PHP7",
       "orm": "Raw",
       "orm": "Raw",
       "platform": ".NET",
       "platform": ".NET",
-      "webserver": "None",
+      "webserver": "Kestrel",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
       "display_name": "Peachpie",
       "display_name": "Peachpie",

+ 9 - 9
frameworks/PHP/peachpie/peachpie.dockerfile

@@ -1,11 +1,11 @@
-FROM microsoft/dotnet:2.0-sdk-jessie
+FROM microsoft/dotnet:2.1-sdk-stretch AS build
+WORKDIR /app
+COPY . .
+RUN dotnet publish -c Release -o ../out Server
 
 
-ADD ./ /peachpie
-WORKDIR /peachpie
+FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime
+ENV COMPlus_ReadyToRun 0
+WORKDIR /app
+COPY --from=build /app/out ./
 
 
-ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE true
-ENV DOTNET_CLI_TELEMETRY_OPTOUT true
-
-ENV PATH="/root/.dotnet:${PATH}"
-
-CMD dotnet run -p Server -c Release
+ENTRYPOINT ["dotnet", "Server.dll"]