File tree Expand file tree Collapse file tree 4 files changed +29
-9
lines changed
Expand file tree Collapse file tree 4 files changed +29
-9
lines changed Original file line number Diff line number Diff line change 77
88 $ sock = filter_var ($ host , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ? SWOOLE_SOCK_TCP : SWOOLE_SOCK_TCP6 ;
99
10- $ server = new Swoole \Http \Server (
11- $ host ,
12- $ serverState ['port ' ] ?? 8000 ,
13- $ config ['swoole ' ]['mode ' ] ?? SWOOLE_PROCESS ,
14- ($ config ['swoole ' ]['ssl ' ] ?? false )
15- ? $ sock | SWOOLE_SSL
16- : $ sock ,
17- );
10+ $ unixSock = $ serverState ['sock ' ] ?? null ;
11+ if (is_string ($ unixSock ) && str_starts_with ($ unixSock , '/ ' )) {
12+ $ server = new Swoole \Http \Server (
13+ $ unixSock , // Use UNIX socket
14+ 0 , // Port is not needed
15+ $ config ['swoole ' ]['mode ' ] ?? SWOOLE_PROCESS ,
16+ SWOOLE_SOCK_UNIX_STREAM
17+ );
18+ } else {
19+ $ server = new Swoole \Http \Server (
20+ $ host ,
21+ $ serverState ['port ' ] ?? 8000 ,
22+ $ config ['swoole ' ]['mode ' ] ?? SWOOLE_PROCESS ,
23+ ($ config ['swoole ' ]['ssl ' ] ?? false )
24+ ? $ sock | SWOOLE_SSL
25+ : $ sock ,
26+ );
27+ }
1828} catch (Throwable $ e ) {
1929 Laravel \Octane \Stream::shutdown ($ e );
2030
Original file line number Diff line number Diff line change @@ -102,9 +102,15 @@ protected function writeServerRunningMessage()
102102 {
103103 $ this ->components ->info ('Server running… ' );
104104
105+ if ($ this ->option ('sock ' )) {
106+ $ str = ' Local: <fg=white;options=bold>unix: ' .$ this ->option ('sock ' ).' </> ' ;
107+ } else {
108+ $ str = ' Local: <fg=white;options=bold> ' .($ this ->hasOption ('https ' ) && $ this ->option ('https ' ) ? 'https:// ' : 'http:// ' ).$ this ->getHost ().': ' .$ this ->getPort ().' </> ' ;
109+ }
110+
105111 $ this ->output ->writeln ([
106112 '' ,
107- ' Local: <fg=white;options=bold> ' .( $ this -> hasOption ( ' https ' ) && $ this -> option ( ' https ' ) ? ' https:// ' : ' http:// ' ). $ this -> getHost (). ' : ' . $ this -> getPort (). ' </> ' ,
113+ $ str ,
108114 '' ,
109115 ' <fg=yellow>Press Ctrl+C to stop the server</> ' ,
110116 '' ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class StartCommand extends Command implements SignalableCommandInterface
1919 {--server= : The server that should be used to serve the application}
2020 {--host= : The IP address the server should bind to}
2121 {--port= : The port the server should be available on [default: "8000"]}
22+ {--sock= : The unix domain socket the server should bind to [Swoole only]}
2223 {--admin-port= : The port the admin server should be available on [FrankenPHP only]}
2324 {--rpc-host= : The RPC IP address the server should bind to}
2425 {--rpc-port= : The RPC port the server should be available on}
@@ -67,6 +68,7 @@ protected function startSwooleServer()
6768 return $ this ->call ('octane:swoole ' , [
6869 '--host ' => $ this ->getHost (),
6970 '--port ' => $ this ->getPort (),
71+ '--sock ' => $ this ->option ('sock ' ),
7072 '--workers ' => $ this ->option ('workers ' ) ?: config ('octane.workers ' , 'auto ' ),
7173 '--task-workers ' => $ this ->option ('task-workers ' ) ?: config ('octane.task_workers ' , 'auto ' ),
7274 '--max-requests ' => $ this ->option ('max-requests ' ) ?: config ('octane.max_requests ' , 500 ),
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ class StartSwooleCommand extends Command implements SignalableCommandInterface
2424 public $ signature = 'octane:swoole
2525 {--host= : The IP address the server should bind to}
2626 {--port= : The port the server should be available on}
27+ {--sock= : The unix socket the server should bind to [Swoole only]}
2728 {--workers=auto : The number of workers that should be available to handle requests}
2829 {--task-workers=auto : The number of task workers that should be available to handle tasks}
2930 {--max-requests=500 : The number of requests to process before reloading the server}
@@ -105,6 +106,7 @@ protected function writeServerStateFile(
105106 'appName ' => config ('app.name ' , 'Laravel ' ),
106107 'host ' => $ this ->getHost (),
107108 'port ' => $ this ->getPort (),
109+ 'sock ' => $ this ->option ('sock ' ),
108110 'workers ' => $ this ->workerCount ($ extension ),
109111 'taskWorkers ' => $ this ->taskWorkerCount ($ extension ),
110112 'maxRequests ' => $ this ->option ('max-requests ' ),
You can’t perform that action at this time.
0 commit comments