sidekiq-unique-jobs 4.0.18 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sidekiq-unique-jobs might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.codeclimate.yml +42 -7
- data/.csslintrc +2 -0
- data/.eslintignore +1 -0
- data/.eslintrc +213 -0
- data/.gitignore +2 -0
- data/.rspec +1 -2
- data/.rubocop.yml +19 -0
- data/.simplecov +2 -1
- data/.travis.yml +8 -12
- data/Appraisals +10 -20
- data/CHANGELOG.md +4 -0
- data/Gemfile +10 -6
- data/README.md +16 -2
- data/Rakefile +1 -0
- data/bin/bench +1 -0
- data/bin/jobs +1 -0
- data/circle.yml +6 -3
- data/gemfiles/sidekiq_4.0.gemfile +8 -5
- data/gemfiles/sidekiq_4.1.gemfile +8 -5
- data/gemfiles/{sidekiq_3.1.gemfile → sidekiq_4.2.gemfile} +9 -6
- data/gemfiles/{sidekiq_3.2.gemfile → sidekiq_5.0.gemfile} +9 -6
- data/gemfiles/sidekiq_develop.gemfile +8 -5
- data/lib/sidekiq-unique-jobs.rb +1 -1
- data/lib/sidekiq_unique_jobs/config.rb +1 -9
- data/lib/sidekiq_unique_jobs/constants.rb +1 -0
- data/lib/sidekiq_unique_jobs/core_ext.rb +44 -34
- data/lib/sidekiq_unique_jobs/lock/while_executing.rb +1 -1
- data/lib/sidekiq_unique_jobs/script_mock.rb +4 -7
- data/lib/sidekiq_unique_jobs/scripts.rb +9 -8
- data/lib/sidekiq_unique_jobs/testing/sidekiq_overrides.rb +23 -17
- data/lib/sidekiq_unique_jobs/unique_args.rb +1 -1
- data/lib/sidekiq_unique_jobs/unlockable.rb +8 -15
- data/lib/sidekiq_unique_jobs/util.rb +7 -0
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/rails_example/.env.test +12 -0
- data/rails_example/.rspec +1 -1
- data/rails_example/Gemfile +12 -9
- data/rails_example/app/controllers/work_controller.rb +16 -2
- data/rails_example/app/models/guest.rb +8 -11
- data/rails_example/app/workers/simple_worker.rb +4 -1
- data/rails_example/app/workers/slow_until_executing_worker.rb +15 -0
- data/rails_example/app/workers/spawn_simple_worker.rb +3 -0
- data/rails_example/app/workers/without_argument_worker.rb +12 -0
- data/rails_example/bin/check_or_setup_db +0 -1
- data/rails_example/common-services.yml +2 -0
- data/rails_example/config/database.yml +2 -2
- data/rails_example/config/environments/development.rb +1 -1
- data/rails_example/config/environments/test.rb +1 -1
- data/rails_example/config/initializers/sidekiq.rb +1 -1
- data/rails_example/config/routes.rb +1 -0
- data/rails_example/config/spring.rb +2 -2
- data/rails_example/docker-compose.yml +19 -38
- data/rails_example/spec/controllers/work_controller_mock_spec.rb +91 -0
- data/rails_example/spec/controllers/work_controller_spec.rb +46 -141
- data/rails_example/spec/rails_helper.rb +1 -2
- data/sidekiq-unique-jobs.gemspec +6 -4
- data/spec/jobs/custom_queue_job.rb +1 -2
- data/spec/jobs/just_a_worker.rb +1 -2
- data/spec/jobs/long_running_job.rb +1 -2
- data/spec/jobs/main_job.rb +1 -2
- data/spec/jobs/my_unique_job.rb +1 -2
- data/spec/jobs/plain_class.rb +1 -2
- data/spec/jobs/test_class.rb +1 -2
- data/spec/jobs/until_and_while_executing_job.rb +1 -2
- data/spec/jobs/until_executing_job.rb +1 -2
- data/spec/jobs/without_argument_job.rb +9 -0
- data/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb +6 -3
- data/spec/lib/sidekiq_unique_jobs/config_spec.rb +84 -0
- data/spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb +2 -1
- data/spec/lib/sidekiq_unique_jobs/lock/while_executing_spec.rb +2 -2
- data/spec/lib/sidekiq_unique_jobs/script_mock_spec.rb +12 -6
- data/spec/lib/sidekiq_unique_jobs/scripts_spec.rb +0 -5
- data/spec/lib/sidekiq_unique_jobs/sidekiq_testing_enabled_spec.rb +5 -3
- data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_ext_spec.rb +2 -2
- data/spec/lib/sidekiq_unique_jobs/unique_args_spec.rb +23 -7
- data/spec/lib/sidekiq_unique_jobs/unlockable_spec.rb +34 -0
- data/spec/lib/sidekiq_unique_jobs/util_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -14
- data/spec/support/ruby_meta.rb +10 -3
- data/spec/support/sidekiq_meta.rb +2 -3
- metadata +33 -16
- data/gemfiles/sidekiq_2.15.gemfile +0 -9
- data/gemfiles/sidekiq_2.16.gemfile +0 -9
- data/gemfiles/sidekiq_2.17.gemfile +0 -19
- data/gemfiles/sidekiq_3.0.gemfile +0 -19
- data/gemfiles/sidekiq_3.3.gemfile +0 -19
- data/spec/celluloid_with_fallback.rb +0 -18
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'digest/sha1'
|
3
|
+
require 'concurrent/map'
|
3
4
|
|
4
5
|
module SidekiqUniqueJobs
|
5
6
|
ScriptError = Class.new(StandardError)
|
@@ -8,29 +9,29 @@ module SidekiqUniqueJobs
|
|
8
9
|
LUA_PATHNAME ||= Pathname.new(__FILE__).dirname.join('../../redis').freeze
|
9
10
|
SOURCE_FILES ||= Dir[LUA_PATHNAME.join('**/*.lua')].compact.freeze
|
10
11
|
DEFINED_METHODS ||= [].freeze
|
12
|
+
SCRIPT_SHAS ||= Concurrent::Map.new
|
11
13
|
|
12
14
|
module_function
|
13
15
|
|
14
16
|
extend SingleForwardable
|
15
17
|
def_delegator :SidekiqUniqueJobs, :connection
|
16
18
|
|
17
|
-
def script_shas
|
18
|
-
@script_shas ||= {}
|
19
|
-
end
|
20
|
-
|
21
19
|
def logger
|
22
20
|
Sidekiq.logger
|
23
21
|
end
|
24
22
|
|
25
|
-
def call(file_name, redis_pool, options = {})
|
23
|
+
def call(file_name, redis_pool, options = {}) # rubocop:disable MethodLength
|
26
24
|
connection(redis_pool) do |redis|
|
27
|
-
|
28
|
-
|
25
|
+
if SCRIPT_SHAS[file_name].nil?
|
26
|
+
SCRIPT_SHAS[file_name] = redis.script(:load, script_source(file_name))
|
27
|
+
end
|
28
|
+
redis.evalsha(SCRIPT_SHAS[file_name], options)
|
29
29
|
end
|
30
30
|
rescue Redis::CommandError => ex
|
31
31
|
if ex.message == 'NOSCRIPT No matching script. Please use EVAL.'
|
32
|
-
|
32
|
+
SCRIPT_SHAS.delete(file_name)
|
33
33
|
call(file_name, redis_pool, options)
|
34
|
+
raise
|
34
35
|
else
|
35
36
|
raise ScriptError,
|
36
37
|
"#{file_name}.lua\n\n#{ex.message}\n\n#{script_source(file_name)}" \
|
@@ -4,26 +4,30 @@ module Sidekiq
|
|
4
4
|
module Worker
|
5
5
|
module ClassMethods
|
6
6
|
# Drain and run all jobs for this worker
|
7
|
-
|
8
|
-
|
7
|
+
unless Sidekiq::Testing.respond_to?(:server_middleware)
|
8
|
+
def drain
|
9
|
+
while (job = jobs.shift)
|
10
|
+
worker = new
|
11
|
+
worker.jid = job['jid']
|
12
|
+
worker.bid = job['bid'] if worker.respond_to?(:bid=)
|
13
|
+
execute_job(worker, job['args'])
|
14
|
+
unlock(job) if Sidekiq::Testing.fake?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Pop out a single job and perform it
|
20
|
+
unless Sidekiq::Testing.respond_to?(:server_middleware)
|
21
|
+
def perform_one
|
22
|
+
raise(EmptyQueueError, 'perform_one called with empty job queue') if jobs.empty?
|
23
|
+
job = jobs.shift
|
9
24
|
worker = new
|
10
25
|
worker.jid = job['jid']
|
11
26
|
worker.bid = job['bid'] if worker.respond_to?(:bid=)
|
12
27
|
execute_job(worker, job['args'])
|
13
28
|
unlock(job) if Sidekiq::Testing.fake?
|
14
29
|
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Pop out a single job and perform it
|
18
|
-
def perform_one
|
19
|
-
raise(EmptyQueueError, 'perform_one called with empty job queue') if jobs.empty?
|
20
|
-
job = jobs.shift
|
21
|
-
worker = new
|
22
|
-
worker.jid = job['jid']
|
23
|
-
worker.bid = job['bid'] if worker.respond_to?(:bid=)
|
24
|
-
execute_job(worker, job['args'])
|
25
|
-
unlock(job) if Sidekiq::Testing.fake?
|
26
|
-
end unless Sidekiq::Testing.respond_to?(:server_middleware)
|
30
|
+
end
|
27
31
|
|
28
32
|
# Clear all jobs for this worker
|
29
33
|
def clear
|
@@ -37,9 +41,11 @@ module Sidekiq
|
|
37
41
|
# end
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
worker
|
42
|
-
|
44
|
+
unless respond_to?(:execute_job)
|
45
|
+
def execute_job(worker, args)
|
46
|
+
worker.perform(*args)
|
47
|
+
end
|
48
|
+
end
|
43
49
|
|
44
50
|
def unlock(job)
|
45
51
|
SidekiqUniqueJobs::Unlockable.unlock(job)
|
@@ -22,7 +22,7 @@ module SidekiqUniqueJobs
|
|
22
22
|
@worker_class ||= worker_class_constantize(@item[CLASS_KEY])
|
23
23
|
@item[UNIQUE_PREFIX_KEY] ||= unique_prefix
|
24
24
|
@item[UNIQUE_ARGS_KEY] = unique_args(@item[ARGS_KEY]) # SIC! Calculate unique_args unconditionally
|
25
|
-
@item[UNIQUE_DIGEST_KEY]
|
25
|
+
@item[UNIQUE_DIGEST_KEY] = unique_digest
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -7,24 +7,13 @@ module SidekiqUniqueJobs
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def unlock_by_key(unique_key, jid, redis_pool = nil)
|
10
|
-
Scripts.call(:release_lock, redis_pool, keys: [unique_key], argv: [jid])
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def unlock_by_jid(jid, redis_pool = nil)
|
16
|
-
Scripts.call(:release_lock_by_jid, redis_pool, keys: [jid]) do |result|
|
17
|
-
after_unlock(result, __method__)
|
18
|
-
end
|
10
|
+
result = Scripts.call(:release_lock, redis_pool, keys: [unique_key], argv: [jid])
|
11
|
+
after_unlock(result, __method__, unique_key, jid)
|
19
12
|
end
|
20
13
|
|
21
|
-
def
|
22
|
-
|
23
|
-
after_unlock(result, __method__)
|
24
|
-
end
|
25
|
-
end
|
14
|
+
def after_unlock(result, calling_method, unique_key, jid) # rubocop:disable Metrics/MethodLength
|
15
|
+
ensure_job_id_removed(jid)
|
26
16
|
|
27
|
-
def after_unlock(result, calling_method)
|
28
17
|
case result
|
29
18
|
when 1
|
30
19
|
logger.debug { "successfully unlocked #{unique_key}" }
|
@@ -40,6 +29,10 @@ module SidekiqUniqueJobs
|
|
40
29
|
end
|
41
30
|
end
|
42
31
|
|
32
|
+
def ensure_job_id_removed(jid)
|
33
|
+
Sidekiq.redis { |redis| redis.hdel(SidekiqUniqueJobs::HASH_KEY, jid) }
|
34
|
+
end
|
35
|
+
|
43
36
|
def logger
|
44
37
|
Sidekiq.logger
|
45
38
|
end
|
@@ -11,7 +11,14 @@ module SidekiqUniqueJobs
|
|
11
11
|
send("keys_by_#{redis_keys_method}", pattern, count)
|
12
12
|
end
|
13
13
|
|
14
|
+
def unique_key(jid)
|
15
|
+
connection do |redis|
|
16
|
+
redis.hget(SidekiqUniqueJobs::HASH_KEY, jid)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
14
20
|
def del(pattern = SCAN_PATTERN, count = 0, dry_run = true)
|
21
|
+
raise 'Please provide a number of keys to delete greater than zero' if count.zero?
|
15
22
|
logger.debug { "Deleting keys by: #{pattern}" }
|
16
23
|
keys, time = timed { keys(pattern, count) }
|
17
24
|
logger.debug { "#{keys.size} matching keys found in #{time} sec." }
|
@@ -0,0 +1,12 @@
|
|
1
|
+
SECRET_KEY_BASE=10167c7f7654ed02b3557b05b88ece1866a9748a2e8e064016f76cb74ddae38264f7403ba65f301d63c21d770e0ee2ac6906f245e904b3b140d12297f67e0db1
|
2
|
+
APP_DOMAIN=localhost
|
3
|
+
APP_WEB_URL=http://localhost:3000
|
4
|
+
APP_CABLE_URL=ws://localhost:28080
|
5
|
+
WEB_CONSOLE_WHITELISTED_IPS=127.0.0.1 ::1 127.0.0.0/8 ::1
|
6
|
+
DB_HOST=localhost
|
7
|
+
DB_PORT=5432
|
8
|
+
DB_USERNAME=postgres
|
9
|
+
DB_PASSWORD=3x4mpl3
|
10
|
+
DB_POOL=25
|
11
|
+
DB_TIMEOUT=5000
|
12
|
+
DB_REAPING_FREQUENCY=10
|
data/rails_example/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--color
|
2
|
-
--
|
2
|
+
--order random
|
data/rails_example/Gemfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
source 'https://rubygems.org'
|
1
|
+
source 'https://rubygems.org' # rubocop:disable Style/FileName
|
2
2
|
|
3
|
-
ruby '2.
|
3
|
+
ruby '2.4.1'
|
4
4
|
|
5
|
-
gem 'rails', '~> 5.0'
|
6
|
-
gem 'puma'
|
7
|
-
gem 'json'
|
8
5
|
gem 'bigdecimal'
|
6
|
+
gem 'json'
|
7
|
+
gem 'puma'
|
8
|
+
gem 'rails', '~> 5.0'
|
9
9
|
|
10
10
|
platforms :ruby do
|
11
11
|
gem 'pg'
|
@@ -14,11 +14,13 @@ platforms :ruby do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
platforms :jruby do
|
17
|
-
gem 'jruby-openssl'
|
18
|
-
gem 'jdbc-pg'
|
19
17
|
gem 'activerecord-jdbc-adapter'
|
18
|
+
gem 'jdbc-pg'
|
19
|
+
gem 'jruby-openssl'
|
20
20
|
end
|
21
21
|
|
22
|
+
# gem 'sidekiq-unique-jobs'
|
23
|
+
gem 'rack-protection' # , github: 'sinatra/rack-protection'
|
22
24
|
gem 'sidekiq-unique-jobs', path: '../'
|
23
25
|
gem 'sinatra', github: 'sinatra/sinatra'
|
24
26
|
|
@@ -27,8 +29,9 @@ group :development do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
group :development, :test do
|
30
|
-
gem '
|
32
|
+
gem 'dockerspec'
|
31
33
|
gem 'factory_girl_rails'
|
34
|
+
gem 'fuubar'
|
32
35
|
gem 'mock_redis'
|
36
|
+
gem 'rspec-rails'
|
33
37
|
end
|
34
|
-
|
@@ -1,13 +1,27 @@
|
|
1
1
|
class WorkController < ApplicationController
|
2
2
|
def duplicate_simple
|
3
|
-
4.times { SimpleWorker.perform_async(
|
3
|
+
4.times { SimpleWorker.perform_async(unique_argument) }
|
4
|
+
|
5
|
+
redirect_to '/sidekiq'
|
6
|
+
end
|
7
|
+
|
8
|
+
def duplicate_slow
|
9
|
+
4.times { SlowUntilExecutingWorker.perform_async(unique_argument) }
|
4
10
|
|
5
11
|
redirect_to '/sidekiq'
|
6
12
|
end
|
7
13
|
|
8
14
|
def duplicate_nested
|
9
|
-
4.times { SpawnSimpleWorker.perform_async(
|
15
|
+
4.times { SpawnSimpleWorker.perform_async(unique_argument) }
|
10
16
|
|
11
17
|
redirect_to '/sidekiq'
|
12
18
|
end
|
19
|
+
|
20
|
+
def unique_argument
|
21
|
+
params[:id]
|
22
|
+
end
|
23
|
+
|
24
|
+
def safe_params
|
25
|
+
params.permit!(:id)
|
26
|
+
end
|
13
27
|
end
|
@@ -1,21 +1,18 @@
|
|
1
1
|
class Guest
|
2
|
+
GUEST_NAME = 'Guest Visitor'.freeze
|
3
|
+
GUEST_EMAIL = 'unknown@domain.com'.freeze
|
4
|
+
|
2
5
|
def name
|
3
|
-
|
6
|
+
GUEST_NAME
|
4
7
|
end
|
5
8
|
|
6
9
|
def email
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def appear
|
10
|
+
GUEST_EMAIL
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
end
|
13
|
+
def appear; end
|
15
14
|
|
16
|
-
def
|
17
|
-
end
|
15
|
+
def disappear; end
|
18
16
|
|
19
|
-
def away
|
20
|
-
end
|
17
|
+
def away; end
|
21
18
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class SlowUntilExecutingWorker
|
2
|
+
include Sidekiq::Worker
|
3
|
+
sidekiq_options unique: :until_executing,
|
4
|
+
queue: :default,
|
5
|
+
unique_args: (lambda do |args|
|
6
|
+
[args.first]
|
7
|
+
end)
|
8
|
+
|
9
|
+
def perform(some_args)
|
10
|
+
Sidekiq::Logging.with_context(self.class.name) do
|
11
|
+
Sidekiq.logger.debug { "#{__method__}(#{some_args})" }
|
12
|
+
end
|
13
|
+
sleep 15
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class WithoutArgumentWorker
|
2
|
+
include Sidekiq::Worker
|
3
|
+
sidekiq_options unique: :until_executed,
|
4
|
+
log_duplicate_payload: true
|
5
|
+
|
6
|
+
def perform
|
7
|
+
Sidekiq::Logging.with_context(self.class.name) do
|
8
|
+
Sidekiq.logger.debug { __method__.to_s }
|
9
|
+
end
|
10
|
+
sleep 20
|
11
|
+
end
|
12
|
+
end
|
@@ -25,6 +25,8 @@ services:
|
|
25
25
|
# to our redis container:
|
26
26
|
REDIS_URL: redis://redis:6379
|
27
27
|
|
28
|
+
DATABASE_URL: postgresql://postgres:3x4mpl3@postgres:5432/rails_example_dev
|
29
|
+
|
28
30
|
# We'll set the RAILS_ENV and RACK_ENV environment variables to
|
29
31
|
# 'development', so our app containers will start in 'development' mode
|
30
32
|
# on this compose project:
|
@@ -3,8 +3,8 @@ defaults: &defaults
|
|
3
3
|
adapter: postgresql
|
4
4
|
host: <%= ENV.fetch('DB_HOST') { 'localhost' } %>
|
5
5
|
port: <%= ENV.fetch('DB_PORT') { 5432 } %>
|
6
|
-
username: <%= ENV.fetch('DB_USERNAME') { '
|
7
|
-
password: <%= ENV.fetch('DB_PASSWORD') {
|
6
|
+
username: <%= ENV.fetch('DB_USERNAME') { 'mhenrixon' } %>
|
7
|
+
password: <%= ENV.fetch('DB_PASSWORD') { nil } %>
|
8
8
|
pool: <%= ENV.fetch('DB_POOL') { 25 } %>
|
9
9
|
timeout: <%= ENV.fetch('DB_TIMEOUT') { 5000 } %>
|
10
10
|
reaping_frequency: <%= ENV.fetch('DB_REAPING_FREQUENCY') { 5000 } %>
|
@@ -18,7 +18,7 @@ Rails.application.configure do
|
|
18
18
|
|
19
19
|
config.cache_store = :memory_store
|
20
20
|
config.public_file_server.headers = {
|
21
|
-
'Cache-Control' => 'public, max-age=172800'
|
21
|
+
'Cache-Control' => 'public, max-age=172800',
|
22
22
|
}
|
23
23
|
else
|
24
24
|
config.action_controller.perform_caching = false
|
@@ -15,7 +15,7 @@ Rails.application.configure do
|
|
15
15
|
# Configure public file server for tests with Cache-Control for performance.
|
16
16
|
config.public_file_server.enabled = true
|
17
17
|
config.public_file_server.headers = {
|
18
|
-
'Cache-Control' => 'public, max-age=3600'
|
18
|
+
'Cache-Control' => 'public, max-age=3600',
|
19
19
|
}
|
20
20
|
|
21
21
|
# Show full error reports and disable caching.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
version: '
|
1
|
+
version: '3.1'
|
2
2
|
volumes:
|
3
3
|
postgres-data:
|
4
4
|
driver: local
|
@@ -14,50 +14,31 @@ networks:
|
|
14
14
|
driver: bridge
|
15
15
|
|
16
16
|
services:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
rspec:
|
18
|
+
image: ruby:2.4
|
19
|
+
working_dir: /usr/src/app
|
20
|
+
stdin_open: true
|
21
|
+
tty: true
|
22
|
+
volumes:
|
23
|
+
- .:/usr/src/app
|
24
|
+
- gems:/usr/local/bundle
|
21
25
|
entrypoint: /usr/src/app/dev-entrypoint.sh
|
22
|
-
command: bundle exec
|
26
|
+
command: bundle exec rspec
|
23
27
|
networks:
|
24
28
|
- back-tier
|
25
|
-
depends_on:
|
26
|
-
- postgres
|
27
|
-
- redis
|
28
|
-
|
29
|
-
web:
|
30
|
-
extends:
|
31
|
-
file: common-services.yml
|
32
|
-
service: rails
|
33
|
-
entrypoint: /usr/src/app/dev-entrypoint.sh
|
34
|
-
command: bundle exec puma --bind tcp://0.0.0.0:3000
|
35
|
-
ports:
|
36
|
-
- 3000:3000
|
37
|
-
networks:
|
38
29
|
- front-tier
|
39
|
-
- back-tier
|
40
|
-
depends_on:
|
41
|
-
- postgres
|
42
|
-
- redis
|
43
|
-
|
44
|
-
cable:
|
45
|
-
extends:
|
46
|
-
file: common-services.yml
|
47
|
-
service: rails
|
48
|
-
entrypoint: /usr/src/app/dev-entrypoint.sh
|
49
|
-
command: bundle exec puma --bind tcp://0.0.0.0:28080 cable.ru
|
50
|
-
ports:
|
51
|
-
- 28080:28080
|
52
|
-
networks:
|
53
|
-
- front-tier
|
54
|
-
- back-tier
|
55
30
|
depends_on:
|
56
31
|
- postgres
|
57
32
|
- redis
|
33
|
+
environment:
|
34
|
+
PATH: /usr/src/app/bin:/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
35
|
+
REDIS_URL: redis://redis:6379
|
36
|
+
DATABASE_URL: postgresql://postgres:3x4mpl3@postgres:5433/rails_example_test
|
37
|
+
RAILS_ENV: test
|
38
|
+
RACK_ENV: test
|
58
39
|
|
59
40
|
redis:
|
60
|
-
image: redis
|
41
|
+
image: redis:latest
|
61
42
|
ports:
|
62
43
|
# We'll bind our host's port 6379 to redis's port 6379, so we can use
|
63
44
|
# Redis Desktop Manager (or other tools) with it:
|
@@ -72,11 +53,11 @@ services:
|
|
72
53
|
|
73
54
|
|
74
55
|
postgres:
|
75
|
-
image: postgres
|
56
|
+
image: postgres:latest
|
76
57
|
ports:
|
77
58
|
# We'll bind our host's port 5432 to postgres's port 5432, so we can use
|
78
59
|
# our database IDEs with it:
|
79
|
-
-
|
60
|
+
- 5433:5433
|
80
61
|
volumes:
|
81
62
|
# We'll store the postgres data in the 'postgres-data' volume we defined:
|
82
63
|
- postgres-data:/var/lib/postgresql/data
|