Skip to content
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

Add sidekiq gem #2738

Merged
merged 7 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @icarito , I have added redis image here. Does it require anything else?
I have tested it locally using docker-compose up and it went well I guess. Please have a look!!
Thanks!!

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