Skip to content

Commit 636b671

Browse files
prashantvtianon
authored andcommitted
Add support for unix domain sockets
1 parent c674e9c commit 636b671

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

apache/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,16 @@ EOPHP
131131
132132
$stderr = fopen('php://stderr', 'w');
133133
134-
list($host, $port) = explode(':', $argv[1], 2);
134+
list($host, $port_or_socket) = explode(':', $argv[1], 2);
135+
if ( 0 !== strpos( $port_or_socket, '/' ) ) {
136+
$port = (int)$port_or_socket;
137+
} else {
138+
$socket = $port_or_socket;
139+
}
135140
136141
$maxTries = 10;
137142
do {
138-
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int)$port);
143+
$mysql = new mysqli($host, $argv[2], $argv[3], '', $port, $socket);
139144
if ($mysql->connect_error) {
140145
fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
141146
--$maxTries;

docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,16 @@ EOPHP
131131
132132
$stderr = fopen('php://stderr', 'w');
133133
134-
list($host, $port) = explode(':', $argv[1], 2);
134+
list($host, $port_or_socket) = explode(':', $argv[1], 2);
135+
if ( 0 !== strpos( $port_or_socket, '/' ) ) {
136+
$port = (int)$port_or_socket;
137+
} else {
138+
$socket = $port_or_socket;
139+
}
135140
136141
$maxTries = 10;
137142
do {
138-
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int)$port);
143+
$mysql = new mysqli($host, $argv[2], $argv[3], '', $port, $socket);
139144
if ($mysql->connect_error) {
140145
fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
141146
--$maxTries;

fpm/docker-entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,16 @@ EOPHP
131131
132132
$stderr = fopen('php://stderr', 'w');
133133
134-
list($host, $port) = explode(':', $argv[1], 2);
134+
list($host, $port_or_socket) = explode(':', $argv[1], 2);
135+
if ( 0 !== strpos( $port_or_socket, '/' ) ) {
136+
$port = (int)$port_or_socket;
137+
} else {
138+
$socket = $port_or_socket;
139+
}
135140
136141
$maxTries = 10;
137142
do {
138-
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int)$port);
143+
$mysql = new mysqli($host, $argv[2], $argv[3], '', $port, $socket);
139144
if ($mysql->connect_error) {
140145
fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
141146
--$maxTries;

0 commit comments

Comments
 (0)