@@ -97,13 +97,6 @@ class Http
9797 */
9898 protected static array $ startHooks = [];
9999
100- /**
101- * Worker Start hooks
102- *
103- * @var Hook[]
104- */
105- protected static array $ workerStartHooks = [];
106-
107100 /**
108101 * Request hooks
109102 *
@@ -563,13 +556,6 @@ protected function getFileMimeType(string $uri): mixed
563556 return $ this ->files ->getFileMimeType ($ uri );
564557 }
565558
566- public static function onWorkerStart (): Hook
567- {
568- $ hook = new Hook ();
569- self ::$ workerStartHooks [] = $ hook ;
570- return $ hook ;
571- }
572-
573559 public static function onStart (): Hook
574560 {
575561 $ hook = new Hook ();
@@ -623,40 +609,6 @@ public function start()
623609 }
624610 });
625611
626- $ this ->server ->onWorkerStart (function ($ server , $ workerId ) {
627- $ this ->resources ['utopia ' ] ??= [];
628- $ this ->resources ['utopia ' ]['server ' ] = $ server ;
629- $ this ->resources ['utopia ' ]['workerId ' ] = $ workerId ;
630-
631- self ::setResource ('server ' , function () use ($ server ) {
632- return $ server ;
633- });
634- self ::setResource ('workerId ' , function () use ($ workerId ) {
635- return $ workerId ;
636- });
637-
638- try {
639-
640- foreach (self ::$ workerStartHooks as $ hook ) {
641- $ arguments = $ this ->getArguments ($ hook , 'utopia ' , [], []);
642- \call_user_func_array ($ hook ->getAction (), $ arguments );
643- }
644- } catch (\Exception $ e ) {
645- self ::setResource ('error ' , fn () => $ e );
646-
647- foreach (self ::$ errors as $ error ) { // Global error hooks
648- if (in_array ('* ' , $ error ->getGroups ())) {
649- try {
650- $ arguments = $ this ->getArguments ($ error , 'utopia ' , [], []);
651- \call_user_func_array ($ error ->getAction (), $ arguments );
652- } catch (\Throwable $ e ) {
653- throw new Exception ('Error handler had an error: ' . $ e ->getMessage (), 500 , $ e );
654- }
655- }
656- }
657- }
658- });
659-
660612 $ this ->server ->start ();
661613 }
662614
@@ -1004,7 +956,6 @@ public static function reset(): void
1004956 self ::$ init = [];
1005957 self ::$ shutdown = [];
1006958 self ::$ options = [];
1007- self ::$ workerStartHooks = [];
1008959 self ::$ startHooks = [];
1009960 }
1010961}
0 commit comments