Skip to content

Commit

Permalink
Add sidekiq gem (#2738)
Browse files Browse the repository at this point in the history
* added resque gem

* made changes for resqu installation

* added sidekiq gem

* minor changes

* modified docker-compose.yml for redis

* minor changes

* resolve conflicts
  • Loading branch information
ViditChitkara authored and jywarren committed Jun 5, 2018
1 parent 393f1a6 commit 539229b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ gem 'rails-i18n', '~> 4.0.0'
gem 'responders', '~> 2.0' # for Rails 4.2

gem 'turbolinks'
gem 'sidekiq'

# Whenever provides a clear syntax for writing and deploying cron jobs
gem 'whenever', require: false
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def reset_user_password
# send key to user email
PasswordResetMailer.reset_notify(user, key).deliver_now unless user.nil? # respond the same to both successes and failures; security
end

flash[:notice] = "#{user.name} should receive an email with instructions on how to reset their password. If they do not, please double check that they are using the email they registered with."
flash[:notice] = "#{user.name} should receive an email with instructions on how to reset their password. If they do not, please double check that they are using the email they registered with."
redirect_to URI.parse("/profile/" + user.name).path
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/relationships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def create
def destroy
user = Relationship.find(params[:id]).followed
current_user.unfollow(user)
redirect_to "/profile/#{user.username}"
redirect_to URI.parse("/profile/#{user.username}").path
end

private
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Application < Rails::Application
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
config.active_job.queue_adapter = :sidekiq

# Enable the asset pipeline
config.assets.enabled = true
Expand Down
9 changes: 9 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sidekiq_config = { url: ENV['JOB_WORKER_URL'] }

Sidekiq.configure_server do |config|
config.redis = sidekiq_config
end

Sidekiq.configure_client do |config|
config.redis = sidekiq_config
end
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
- ../dump:/docker-entrypoint-initdb.d
# for importing a dump
# if you want to re-import simply put away ../mysql/*
redis:
image: redis:latest
web:
build: .
command: /bin/bash -c "sleep 5 && passenger start -p 4000"
Expand All @@ -27,3 +29,13 @@ services:
ports:
- "127.0.0.1:4000:4000"
restart: unless-stopped
sidekiq:
build: .
command: bundle exec sidekiq
depends_on:
- db
- redis
volumes:
- .:/app
environment:
- JOB_WORKER_URL=redis://redis:6379/0

0 comments on commit 539229b

Please sign in to comment.