Browse Source

Change process mode (#5247)

Enable opcache
Yurun 5 years ago
parent
commit
3e7918e502

+ 1 - 1
frameworks/PHP/imi/ApiServer/Controller/IndexController.php

@@ -32,7 +32,7 @@ class IndexController extends HttpController
      */
     public function plaintext()
     {
-        return RequestContext::get('response')->withHeader('Content-Type', 'text/plain')->write('Hello, World!');
+        return RequestContext::get('response')->withHeader('Content-Type', 'text/plain; charset=utf-8')->write('Hello, World!');
     }
 
     /**

+ 5 - 0
frameworks/PHP/imi/config/config.php

@@ -26,6 +26,7 @@ return [
         'type'      =>  Imi\Server\Type::HTTP,
         'host'      =>  '0.0.0.0',
         'port'      =>  8080,
+        'mode'      =>  SWOOLE_BASE,
         'configs'   =>  [
             'worker_num'        => swoole_cpu_num(),
             'open_tcp_nodelay'  => true,
@@ -47,6 +48,8 @@ return [
                         'maxResources' => 512,
                         // 池子中最少资源数
                         'minResources' => 0,
+                        'gcInterval'   => null,
+                        'checkStateWhenGetResource' =>  false,
                     ],
                 ],
                 // resource也可以定义多个连接
@@ -61,6 +64,8 @@ return [
                         'maxResources' => 512,
                         // 池子中最少资源数
                         'minResources' => 16,
+                        'gcInterval'   => null,
+                        'checkStateWhenGetResource' =>  false,
                     ],
                 ],
                 // resource也可以定义多个连接

+ 2 - 1
frameworks/PHP/imi/imi.dockerfile

@@ -11,6 +11,7 @@ RUN apt -yqq update > /dev/null && \
 WORKDIR /imi
 
 COPY . /imi
+COPY php.ini /usr/local/etc/php/
 
 RUN chmod -R ug+rwx /imi/.runtime
 
@@ -18,4 +19,4 @@ RUN curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/loca
 RUN composer install --no-dev --classmap-authoritative --quiet > /dev/null
 RUN composer dumpautoload -o
 
-CMD php vendor/bin/imi server/start -name main
+CMD php vendor/bin/imi server/start

+ 2 - 0
frameworks/PHP/imi/php.ini

@@ -0,0 +1,2 @@
+opcache.enable_cli=1
+opcache.validate_timestamps=0