New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Redis host to be configurable through environment #1578

Closed
jackwakefield opened this Issue Aug 31, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@jackwakefield

jackwakefield commented Aug 31, 2017

The Redis configuration in statamic/config/database.php is currently hardcoded as

'redis' => [

    'cluster' => false,

    'default' => [
        'host'     => '127.0.0.1',
        'port'     => 6379,
        'database' => 0,
    ],

]

This is an issue when the Redis server is located anywhere but localhost, for example when the Redis server is hosted within a separate Docker container.

Server Details

Operating System: CentOS 6.9

Web Server: Apache 2.4

PHP Version: 7.1.7

Statamic Version: 2.6.8

Updated from an older Statamic or fresh install: Updated

List of installed addons: Custom project-specific addons

@jackwakefield

This comment has been minimized.

Show comment
Hide comment
@jackwakefield

jackwakefield Sep 1, 2017

A patch for this could be

diff --git a/statamic/config/database.php b/statamic/config/database.php
--- a/statamic/config/database.php
+++ b/statamic/config/database.php
@@ -115,9 +115,9 @@ return [
         'cluster' => false,

         'default' => [
-            'host'     => '127.0.0.1',
-            'port'     => 6379,
-            'database' => 0,
+            'host'     => env('REDIS_HOST', '127.0.0.1'),
+            'port'     => env('REDIS_PORT', 6379),
+            'database' => env('REDIS_DATABASE', 0),
         ],

     ],

jackwakefield commented Sep 1, 2017

A patch for this could be

diff --git a/statamic/config/database.php b/statamic/config/database.php
--- a/statamic/config/database.php
+++ b/statamic/config/database.php
@@ -115,9 +115,9 @@ return [
         'cluster' => false,

         'default' => [
-            'host'     => '127.0.0.1',
-            'port'     => 6379,
-            'database' => 0,
+            'host'     => env('REDIS_HOST', '127.0.0.1'),
+            'port'     => env('REDIS_PORT', 6379),
+            'database' => env('REDIS_DATABASE', 0),
         ],

     ],
@jasonvarga

This comment has been minimized.

Show comment
Hide comment
@jasonvarga

jasonvarga Sep 1, 2017

Member

What Statamic version are you on?

I was going to say the code already reflects your patch. I was looking in another Laravel project 😊

Member

jasonvarga commented Sep 1, 2017

What Statamic version are you on?

I was going to say the code already reflects your patch. I was looking in another Laravel project 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment