octane.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. use Laravel\Octane\Contracts\OperationTerminated;
  3. use Laravel\Octane\Events\RequestHandled;
  4. use Laravel\Octane\Events\RequestReceived;
  5. use Laravel\Octane\Events\RequestTerminated;
  6. use Laravel\Octane\Events\TaskReceived;
  7. use Laravel\Octane\Events\TaskTerminated;
  8. use Laravel\Octane\Events\TickReceived;
  9. use Laravel\Octane\Events\TickTerminated;
  10. use Laravel\Octane\Events\WorkerErrorOccurred;
  11. use Laravel\Octane\Events\WorkerStarting;
  12. use Laravel\Octane\Events\WorkerStopping;
  13. use Laravel\Octane\Listeners\CloseMonologHandlers;
  14. use Laravel\Octane\Listeners\CollectGarbage;
  15. use Laravel\Octane\Listeners\DisconnectFromDatabases;
  16. use Laravel\Octane\Listeners\EnsureUploadedFilesAreValid;
  17. use Laravel\Octane\Listeners\EnsureUploadedFilesCanBeMoved;
  18. use Laravel\Octane\Listeners\FlushOnce;
  19. use Laravel\Octane\Listeners\FlushTemporaryContainerInstances;
  20. use Laravel\Octane\Listeners\FlushUploadedFiles;
  21. use Laravel\Octane\Listeners\ReportException;
  22. use Laravel\Octane\Listeners\StopWorkerIfNecessary;
  23. use Laravel\Octane\Octane;
  24. return [
  25. /*
  26. |--------------------------------------------------------------------------
  27. | Octane Server
  28. |--------------------------------------------------------------------------
  29. |
  30. | This value determines the default "server" that will be used by Octane
  31. | when starting, restarting, or stopping your server via the CLI. You
  32. | are free to change this to the supported server of your choosing.
  33. |
  34. | Supported: "roadrunner", "swoole", "frankenphp"
  35. |
  36. */
  37. 'server' => env('OCTANE_SERVER', 'roadrunner'),
  38. /*
  39. |--------------------------------------------------------------------------
  40. | Force HTTPS
  41. |--------------------------------------------------------------------------
  42. |
  43. | When this configuration value is set to "true", Octane will inform the
  44. | framework that all absolute links must be generated using the HTTPS
  45. | protocol. Otherwise your links may be generated using plain HTTP.
  46. |
  47. */
  48. 'https' => env('OCTANE_HTTPS', false),
  49. /*
  50. |--------------------------------------------------------------------------
  51. | Octane Listeners
  52. |--------------------------------------------------------------------------
  53. |
  54. | All of the event listeners for Octane's events are defined below. These
  55. | listeners are responsible for resetting your application's state for
  56. | the next request. You may even add your own listeners to the list.
  57. |
  58. */
  59. 'listeners' => [
  60. WorkerStarting::class => [
  61. EnsureUploadedFilesAreValid::class,
  62. EnsureUploadedFilesCanBeMoved::class,
  63. ],
  64. RequestReceived::class => [
  65. ...Octane::prepareApplicationForNextOperation(),
  66. ...Octane::prepareApplicationForNextRequest(),
  67. //
  68. ],
  69. RequestHandled::class => [
  70. //
  71. ],
  72. RequestTerminated::class => [
  73. // FlushUploadedFiles::class,
  74. ],
  75. TaskReceived::class => [
  76. ...Octane::prepareApplicationForNextOperation(),
  77. //
  78. ],
  79. TaskTerminated::class => [
  80. //
  81. ],
  82. TickReceived::class => [
  83. ...Octane::prepareApplicationForNextOperation(),
  84. //
  85. ],
  86. TickTerminated::class => [
  87. //
  88. ],
  89. OperationTerminated::class => [
  90. FlushOnce::class,
  91. FlushTemporaryContainerInstances::class,
  92. // DisconnectFromDatabases::class,
  93. // CollectGarbage::class,
  94. ],
  95. WorkerErrorOccurred::class => [
  96. ReportException::class,
  97. StopWorkerIfNecessary::class,
  98. ],
  99. WorkerStopping::class => [
  100. CloseMonologHandlers::class,
  101. ],
  102. ],
  103. /*
  104. |--------------------------------------------------------------------------
  105. | Warm / Flush Bindings
  106. |--------------------------------------------------------------------------
  107. |
  108. | The bindings listed below will either be pre-warmed when a worker boots
  109. | or they will be flushed before every new request. Flushing a binding
  110. | will force the container to resolve that binding again when asked.
  111. |
  112. */
  113. 'warm' => [
  114. ...Octane::defaultServicesToWarm(),
  115. ],
  116. 'flush' => [
  117. //
  118. ],
  119. /*
  120. |--------------------------------------------------------------------------
  121. | Octane Swoole Tables
  122. |--------------------------------------------------------------------------
  123. |
  124. | While using Swoole, you may define additional tables as required by the
  125. | application. These tables can be used to store data that needs to be
  126. | quickly accessed by other workers on the particular Swoole server.
  127. |
  128. */
  129. 'tables' => [
  130. 'example:1000' => [
  131. 'name' => 'string:1000',
  132. 'votes' => 'int',
  133. ],
  134. ],
  135. /*
  136. |--------------------------------------------------------------------------
  137. | Octane Swoole Cache Table
  138. |--------------------------------------------------------------------------
  139. |
  140. | While using Swoole, you may leverage the Octane cache, which is powered
  141. | by a Swoole table. You may set the maximum number of rows as well as
  142. | the number of bytes per row using the configuration options below.
  143. |
  144. */
  145. 'cache' => [
  146. 'rows' => 1000,
  147. 'bytes' => 10000,
  148. ],
  149. /*
  150. |--------------------------------------------------------------------------
  151. | File Watching
  152. |--------------------------------------------------------------------------
  153. |
  154. | The following list of files and directories will be watched when using
  155. | the --watch option offered by Octane. If any of the directories and
  156. | files are changed, Octane will automatically reload your workers.
  157. |
  158. */
  159. 'watch' => [
  160. 'app',
  161. 'bootstrap',
  162. 'config/**/*.php',
  163. 'database/**/*.php',
  164. 'public/**/*.php',
  165. 'resources/**/*.php',
  166. 'routes',
  167. 'composer.lock',
  168. '.env',
  169. ],
  170. /*
  171. |--------------------------------------------------------------------------
  172. | Garbage Collection Threshold
  173. |--------------------------------------------------------------------------
  174. |
  175. | When executing long-lived PHP scripts such as Octane, memory can build
  176. | up before being cleared by PHP. You can force Octane to run garbage
  177. | collection if your application consumes this amount of megabytes.
  178. |
  179. */
  180. 'garbage' => 50,
  181. /*
  182. |--------------------------------------------------------------------------
  183. | Maximum Execution Time
  184. |--------------------------------------------------------------------------
  185. |
  186. | The following setting configures the maximum execution time for requests
  187. | being handled by Octane. You may set this value to 0 to indicate that
  188. | there isn't a specific time limit on Octane request execution time.
  189. |
  190. */
  191. 'max_execution_time' => 180,
  192. ];