fix: empty db conf

feat: add listen_addresses to postgresql if its missing in the custom conf
This commit is contained in:
Andras Bacsai 2024-05-07 12:35:24 +02:00
parent d0e9d58a43
commit 2b422a542a
6 changed files with 17 additions and 15 deletions

View File

@ -96,7 +96,7 @@ class StartKeydb
if (count($volume_names) > 0) { if (count($volume_names) > 0) {
$docker_compose['volumes'] = $volume_names; $docker_compose['volumes'] = $volume_names;
} }
if (!is_null($this->database->keydb_conf)) { if (!is_null($this->database->keydb_conf) || !empty($this->database->keydb_conf)) {
$docker_compose['services'][$container_name]['volumes'][] = [ $docker_compose['services'][$container_name]['volumes'][] = [
'type' => 'bind', 'type' => 'bind',
'source' => $this->configuration_dir . '/keydb.conf', 'source' => $this->configuration_dir . '/keydb.conf',
@ -162,7 +162,7 @@ class StartKeydb
} }
private function add_custom_keydb() private function add_custom_keydb()
{ {
if (is_null($this->database->keydb_conf)) { if (is_null($this->database->keydb_conf) || empty($this->database->keydb_conf)) {
return; return;
} }
$filename = 'keydb.conf'; $filename = 'keydb.conf';

View File

@ -90,7 +90,7 @@ class StartMariadb
if (count($volume_names) > 0) { if (count($volume_names) > 0) {
$docker_compose['volumes'] = $volume_names; $docker_compose['volumes'] = $volume_names;
} }
if (!is_null($this->database->mariadb_conf)) { if (!is_null($this->database->mariadb_conf) || !empty($this->database->mariadb_conf)) {
$docker_compose['services'][$container_name]['volumes'][] = [ $docker_compose['services'][$container_name]['volumes'][] = [
'type' => 'bind', 'type' => 'bind',
'source' => $this->configuration_dir . '/custom-config.cnf', 'source' => $this->configuration_dir . '/custom-config.cnf',
@ -165,7 +165,7 @@ class StartMariadb
} }
private function add_custom_mysql() private function add_custom_mysql()
{ {
if (is_null($this->database->mariadb_conf)) { if (is_null($this->database->mariadb_conf) || empty($this->database->mariadb_conf)) {
return; return;
} }
$filename = 'custom-config.cnf'; $filename = 'custom-config.cnf';

View File

@ -97,7 +97,7 @@ class StartMongodb
if (count($volume_names) > 0) { if (count($volume_names) > 0) {
$docker_compose['volumes'] = $volume_names; $docker_compose['volumes'] = $volume_names;
} }
if (!is_null($this->database->mongo_conf)) { if (!is_null($this->database->mongo_conf) || !empty($this->database->mongo_conf)) {
$docker_compose['services'][$container_name]['volumes'][] = [ $docker_compose['services'][$container_name]['volumes'][] = [
'type' => 'bind', 'type' => 'bind',
'source' => $this->configuration_dir . '/mongod.conf', 'source' => $this->configuration_dir . '/mongod.conf',
@ -178,7 +178,7 @@ class StartMongodb
} }
private function add_custom_mongo_conf() private function add_custom_mongo_conf()
{ {
if (is_null($this->database->mongo_conf)) { if (is_null($this->database->mongo_conf) || empty($this->database->mongo_conf)) {
return; return;
} }
$filename = 'mongod.conf'; $filename = 'mongod.conf';

View File

@ -90,7 +90,7 @@ class StartMysql
if (count($volume_names) > 0) { if (count($volume_names) > 0) {
$docker_compose['volumes'] = $volume_names; $docker_compose['volumes'] = $volume_names;
} }
if (!is_null($this->database->mysql_conf)) { if (!is_null($this->database->mysql_conf) || !empty($this->database->mysql_conf)) {
$docker_compose['services'][$container_name]['volumes'][] = [ $docker_compose['services'][$container_name]['volumes'][] = [
'type' => 'bind', 'type' => 'bind',
'source' => $this->configuration_dir . '/custom-config.cnf', 'source' => $this->configuration_dir . '/custom-config.cnf',
@ -165,7 +165,7 @@ class StartMysql
} }
private function add_custom_mysql() private function add_custom_mysql()
{ {
if (is_null($this->database->mysql_conf)) { if (is_null($this->database->mysql_conf) || empty($this->database->mysql_conf)) {
return; return;
} }
$filename = 'custom-config.cnf'; $filename = 'custom-config.cnf';

View File

@ -78,7 +78,6 @@ class StartPostgresql
data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset); data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
} }
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) { if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
ray('Log Drain Enabled');
$docker_compose['services'][$container_name]['logging'] = [ $docker_compose['services'][$container_name]['logging'] = [
'driver' => 'fluentd', 'driver' => 'fluentd',
'options' => [ 'options' => [
@ -107,7 +106,7 @@ class StartPostgresql
]; ];
} }
} }
if (!is_null($this->database->postgres_conf)) { if (!is_null($this->database->postgres_conf) && !empty($this->database->postgres_conf)) {
$docker_compose['services'][$container_name]['volumes'][] = [ $docker_compose['services'][$container_name]['volumes'][] = [
'type' => 'bind', 'type' => 'bind',
'source' => $this->configuration_dir . '/custom-postgres.conf', 'source' => $this->configuration_dir . '/custom-postgres.conf',
@ -165,8 +164,6 @@ class StartPostgresql
private function generate_environment_variables() private function generate_environment_variables()
{ {
$environment_variables = collect(); $environment_variables = collect();
ray('Generate Environment Variables')->green();
ray($this->database->runtime_environment_variables)->green();
foreach ($this->database->runtime_environment_variables as $env) { foreach ($this->database->runtime_environment_variables as $env) {
$environment_variables->push("$env->key=$env->real_value"); $environment_variables->push("$env->key=$env->real_value");
} }
@ -203,11 +200,16 @@ class StartPostgresql
} }
private function add_custom_conf() private function add_custom_conf()
{ {
if (is_null($this->database->postgres_conf)) { if (is_null($this->database->postgres_conf) || empty($this->database->postgres_conf)) {
return; return;
} }
$filename = 'custom-postgres.conf'; $filename = 'custom-postgres.conf';
$content = $this->database->postgres_conf; $content = $this->database->postgres_conf;
if (!str($content)->contains('listen_addresses')) {
$content .= "\nlisten_addresses = '*'";
$this->database->postgres_conf = $content;
$this->database->save();
}
$content_base64 = base64_encode($content); $content_base64 = base64_encode($content);
$this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null"; $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null";
} }

View File

@ -100,7 +100,7 @@ class StartRedis
if (count($volume_names) > 0) { if (count($volume_names) > 0) {
$docker_compose['volumes'] = $volume_names; $docker_compose['volumes'] = $volume_names;
} }
if (!is_null($this->database->redis_conf)) { if (!is_null($this->database->redis_conf) || !empty($this->database->redis_conf)) {
$docker_compose['services'][$container_name]['volumes'][] = [ $docker_compose['services'][$container_name]['volumes'][] = [
'type' => 'bind', 'type' => 'bind',
'source' => $this->configuration_dir . '/redis.conf', 'source' => $this->configuration_dir . '/redis.conf',
@ -166,7 +166,7 @@ class StartRedis
} }
private function add_custom_redis() private function add_custom_redis()
{ {
if (is_null($this->database->redis_conf)) { if (is_null($this->database->redis_conf) || empty($this->database->redis_conf)) {
return; return;
} }
$filename = 'redis.conf'; $filename = 'redis.conf';