X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/eaa1765c7a68cd671bcb37a666203210bf05d217..refs/pull/524/head:/config/database.php diff --git a/config/database.php b/config/database.php index f6cf86b4c..3883b5868 100644 --- a/config/database.php +++ b/config/database.php @@ -1,5 +1,29 @@ env('REDIS_CLUSTER', false) + ]; + foreach ($redisServers as $index => $redisServer) { + $redisServerName = ($index === 0) ? 'default' : 'redis-server-' . $index; + $redisServerDetails = explode(':', $redisServer); + if (count($redisServerDetails) < 2) $redisServerDetails[] = '6379'; + if (count($redisServerDetails) < 3) $redisServerDetails[] = '0'; + $redisConfig[$redisServerName] = array_combine($redisServerKeys, $redisServerDetails); + } +} + +$mysql_host = env('DB_HOST', 'localhost'); +$mysql_host_exploded = explode(':', $mysql_host); +$mysql_port = env('DB_PORT', 3306); +if (count($mysql_host_exploded) > 1) { + $mysql_host = $mysql_host_exploded[0]; + $mysql_port = intval($mysql_host_exploded[1]); +} + return [ /* @@ -54,10 +78,23 @@ return [ 'mysql' => [ 'driver' => 'mysql', - 'host' => env('DB_HOST', 'localhost'), + 'host' => $mysql_host, 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), + 'port' => $mysql_port, + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'strict' => false, + ], + + 'mysql_testing' => [ + 'driver' => 'mysql', + 'host' => '127.0.0.1', + 'database' => 'bookstack-test', + 'username' => env('MYSQL_USER', 'bookstack-test'), + 'password' => env('MYSQL_PASSWORD', 'bookstack-test'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', @@ -111,16 +148,6 @@ return [ | */ - 'redis' => [ - - 'cluster' => false, - - 'default' => [ - 'host' => '127.0.0.1', - 'port' => 6379, - 'database' => 0, - ], - - ], + 'redis' => env('REDIS_SERVERS', false) ? $redisConfig : [], ];