Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

improve custom redis.conf

peaklabs-dev902cde59057e
diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php
index eeddab924a..186ad0432f 100644
--- a/app/Actions/Database/StartRedis.php
+++ b/app/Actions/Database/StartRedis.php
@@ -37,6 +37,8 @@ class StartRedis
$environment_variables = $this->generate_environment_variables();
$this->add_custom_redis();
+ $startCommand = $this->buildStartCommand();
+
$docker_compose = [
'services' => [
$container_name => [
@@ -105,7 +107,6 @@ class StartRedis
'target' => '/usr/local/etc/redis/redis.conf',
'read_only' => true,
];
- $docker_compose['services'][$container_name]['command'] = "redis-server /usr/local/etc/redis/redis.conf --requirepass {$this->database->redis_password} --appendonly yes";
}
// Add custom docker run options
@@ -173,6 +174,27 @@ class StartRedis
return $environment_variables->all();
}
+ private function buildStartCommand(): string
+ {
+ $hasRedisConf = ! is_null($this->database->redis_conf) && ! empty($this->database->redis_conf);
+ $redisConfPath = '/usr/local/etc/redis/redis.conf';
+
+ if ($hasRedisConf) {
+ $confContent = $this->database->redis_conf;
+ $hasRequirePass = str_contains($confContent, 'requirepass');
+
+ if ($hasRequirePass) {
+ $command = "redis-server $redisConfPath";
+ } else {
+ $command = "redis-server $redisConfPath --requirepass {$this->database->redis_password}";
+ }
+ } else {
+ $command = "redis-server --requirepass {$this->database->redis_password} --appendonly yes";
+ }
+
+ return $command;
+ }
+
private function add_custom_redis()
{
if (is_null($this->database->redis_conf) || empty($this->database->redis_conf)) {