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 7
7
8
8
$ sock = filter_var ($ host , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ? SWOOLE_SOCK_TCP : SWOOLE_SOCK_TCP6 ;
9
9
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
+ }
18
28
} catch (Throwable $ e ) {
19
29
Laravel \Octane \Stream::shutdown ($ e );
20
30
Original file line number Diff line number Diff line change @@ -102,9 +102,15 @@ protected function writeServerRunningMessage()
102
102
{
103
103
$ this ->components ->info ('Server running… ' );
104
104
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
+
105
111
$ this ->output ->writeln ([
106
112
'' ,
107
- ' Local: <fg=white;options=bold> ' .( $ this -> hasOption ( ' https ' ) && $ this -> option ( ' https ' ) ? ' https:// ' : ' http:// ' ). $ this -> getHost (). ' : ' . $ this -> getPort (). ' </> ' ,
113
+ $ str ,
108
114
'' ,
109
115
' <fg=yellow>Press Ctrl+C to stop the server</> ' ,
110
116
'' ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class StartCommand extends Command implements SignalableCommandInterface
19
19
{--server= : The server that should be used to serve the application}
20
20
{--host= : The IP address the server should bind to}
21
21
{--port= : The port the server should be available on [default: "8000"]}
22
+ {--sock= : The unix domain socket the server should bind to [Swoole only]}
22
23
{--admin-port= : The port the admin server should be available on [FrankenPHP only]}
23
24
{--rpc-host= : The RPC IP address the server should bind to}
24
25
{--rpc-port= : The RPC port the server should be available on}
@@ -67,6 +68,7 @@ protected function startSwooleServer()
67
68
return $ this ->call ('octane:swoole ' , [
68
69
'--host ' => $ this ->getHost (),
69
70
'--port ' => $ this ->getPort (),
71
+ '--sock ' => $ this ->option ('sock ' ),
70
72
'--workers ' => $ this ->option ('workers ' ) ?: config ('octane.workers ' , 'auto ' ),
71
73
'--task-workers ' => $ this ->option ('task-workers ' ) ?: config ('octane.task_workers ' , 'auto ' ),
72
74
'--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
24
24
public $ signature = 'octane:swoole
25
25
{--host= : The IP address the server should bind to}
26
26
{--port= : The port the server should be available on}
27
+ {--sock= : The unix socket the server should bind to [Swoole only]}
27
28
{--workers=auto : The number of workers that should be available to handle requests}
28
29
{--task-workers=auto : The number of task workers that should be available to handle tasks}
29
30
{--max-requests=500 : The number of requests to process before reloading the server}
@@ -105,6 +106,7 @@ protected function writeServerStateFile(
105
106
'appName ' => config ('app.name ' , 'Laravel ' ),
106
107
'host ' => $ this ->getHost (),
107
108
'port ' => $ this ->getPort (),
109
+ 'sock ' => $ this ->option ('sock ' ),
108
110
'workers ' => $ this ->workerCount ($ extension ),
109
111
'taskWorkers ' => $ this ->taskWorkerCount ($ extension ),
110
112
'maxRequests ' => $ this ->option ('max-requests ' ),
You can’t perform that action at this time.
0 commit comments