Skip to content

Commit

Permalink
Adding the ability to set a redis password.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo-c committed Sep 10, 2014
1 parent 962b5b0 commit 9e53e09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ If you need a non-default resque server, use this environment variable.
```
RAILS_RESQUE_REDIS=123.x.0.456:6712
```

If you need to set a password for your redis server, use this env variable.

```
RAILS_RESQUE_REDIS_PASSWORD=verys3cureP@ss
```

## Security

You almost certainly want to limit access when using resque-web in production. Using [routes constraints](http://guides.rubyonrails.org/routing.html#request-based-constraints) is one way to achieve this:
Expand Down
9 changes: 9 additions & 0 deletions config/initializers/resque_config.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
config = ENV.fetch("RAILS_RESQUE_REDIS", "127.0.0.1:6379")
Resque.redis = config

# Have to do this to accept password because resque does not support
# setting it in the string.
password = ENV.fetch("RAILS_RESQUE_REDIS_PASSWORD", nil)
unless password.nil?
opts = Resque.redis.client.options
redis = Redis.new(opts.merge(:password => password))
Resque.redis = redis
end

0 comments on commit 9e53e09

Please sign in to comment.