Skip to content

Commit 4fda15d

Browse files
author
ryudo
committed
Merge branch 'external_good_job' into 'development'
Set good_job as external service See merge request 5xruby/daikichi!11
2 parents 146df17 + 5d4fff9 commit 4fda15d

13 files changed

Lines changed: 183 additions & 64 deletions

File tree

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.10
1+
2.7.8

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG APP_ROOT=/src/app
2-
ARG RUBY_VERSION=2.6.10
2+
ARG RUBY_VERSION=2.7.8
33

44
FROM ruby:${RUBY_VERSION}-alpine AS gem
55
ARG APP_ROOT
@@ -66,5 +66,5 @@ RUN bundle exec rake assets:precompile
6666

6767
EXPOSE 3000
6868
HEALTHCHECK CMD curl -f http://localhost:3000/status || exit 1
69-
ENTRYPOINT ["bin/entrypoint"]
69+
ENTRYPOINT ["bin/openbox"]
7070
CMD ["server"]

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source 'https://rubygems.org'
66
gem 'rails', '5.2.8.1'
77
gem 'bootsnap'
88
# Use postgresql as the database for Active Record
9-
gem 'pg', '~> 0.18'
9+
gem 'pg', '~> 1.5.0'
1010
# Use Puma as the app server
1111
gem 'puma', '~> 5.0'
1212
# Use SCSS for stylesheets
@@ -99,3 +99,5 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
9999
gem "postal-rails", "~> 1.0"
100100

101101
gem "good_job", "~> 2.99"
102+
103+
gem "openbox", "~> 0.5.1"

Gemfile.lock

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ GEM
258258
omniauth_openid_connect (0.7.1)
259259
omniauth (>= 1.9, < 3)
260260
openid_connect (~> 2.2)
261+
openbox (0.5.1)
262+
dotenv
263+
thor (~> 1.0)
261264
openid_connect (2.3.0)
262265
activemodel
263266
attr_required (>= 1.0.0)
@@ -278,7 +281,7 @@ GEM
278281
parser (3.3.0.5)
279282
ast (~> 2.4.1)
280283
racc
281-
pg (0.21.0)
284+
pg (1.5.4)
282285
pivot_table (1.0.0)
283286
postal-rails (1.0.1)
284287
postal-ruby (>= 0.0.2, < 2.0)
@@ -469,7 +472,9 @@ GEM
469472

470473
PLATFORMS
471474
x86_64-darwin-21
475+
x86_64-darwin-22
472476
x86_64-linux
477+
x86_64-linux-musl
473478

474479
DEPENDENCIES
475480
aasm (~> 4)
@@ -511,8 +516,9 @@ DEPENDENCIES
511516
momentjs-rails
512517
omniauth (< 2.0)
513518
omniauth_openid_connect (~> 0.7)
519+
openbox (~> 0.5.1)
514520
paranoia (~> 2.2)
515-
pg (~> 0.18)
521+
pg (~> 1.5.0)
516522
pivot_table
517523
postal-rails (~> 1.0)
518524
pry-byebug

bin/bundle

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
11
#!/usr/bin/env ruby
2-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3-
load Gem.bin_path('bundler', 'bundle')
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'bundle' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "rubygems"
12+
13+
m = Module.new do
14+
module_function
15+
16+
def invoked_as_script?
17+
File.expand_path($0) == File.expand_path(__FILE__)
18+
end
19+
20+
def env_var_version
21+
ENV["BUNDLER_VERSION"]
22+
end
23+
24+
def cli_arg_version
25+
return unless invoked_as_script? # don't want to hijack other binstubs
26+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27+
bundler_version = nil
28+
update_index = nil
29+
ARGV.each_with_index do |a, i|
30+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31+
bundler_version = a
32+
end
33+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34+
bundler_version = $1
35+
update_index = i
36+
end
37+
bundler_version
38+
end
39+
40+
def gemfile
41+
gemfile = ENV["BUNDLE_GEMFILE"]
42+
return gemfile if gemfile && !gemfile.empty?
43+
44+
File.expand_path("../Gemfile", __dir__)
45+
end
46+
47+
def lockfile
48+
lockfile =
49+
case File.basename(gemfile)
50+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51+
else "#{gemfile}.lock"
52+
end
53+
File.expand_path(lockfile)
54+
end
55+
56+
def lockfile_version
57+
return unless File.file?(lockfile)
58+
lockfile_contents = File.read(lockfile)
59+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60+
Regexp.last_match(1)
61+
end
62+
63+
def bundler_requirement
64+
@bundler_requirement ||=
65+
env_var_version || cli_arg_version ||
66+
bundler_requirement_for(lockfile_version)
67+
end
68+
69+
def bundler_requirement_for(version)
70+
return "#{Gem::Requirement.default}.a" unless version
71+
72+
bundler_gem_version = Gem::Version.new(version)
73+
74+
requirement = bundler_gem_version.approximate_recommendation
75+
76+
return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
77+
78+
requirement += ".a" if bundler_gem_version.prerelease?
79+
80+
requirement
81+
end
82+
83+
def load_bundler!
84+
ENV["BUNDLE_GEMFILE"] ||= gemfile
85+
86+
activate_bundler
87+
end
88+
89+
def activate_bundler
90+
gem_error = activation_error_handling do
91+
gem "bundler", bundler_requirement
92+
end
93+
return if gem_error.nil?
94+
require_error = activation_error_handling do
95+
require "bundler/version"
96+
end
97+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99+
exit 42
100+
end
101+
102+
def activation_error_handling
103+
yield
104+
nil
105+
rescue StandardError, LoadError => e
106+
e
107+
end
108+
end
109+
110+
m.load_bundler!
111+
112+
if m.invoked_as_script?
113+
load Gem.bin_path("bundler", "bundle")
114+
end

bin/entrypoint

Lines changed: 0 additions & 50 deletions
This file was deleted.

bin/openbox

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'openbox' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12+
13+
bundle_binstub = File.expand_path("bundle", __dir__)
14+
15+
if File.file?(bundle_binstub)
16+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
17+
load(bundle_binstub)
18+
else
19+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21+
end
22+
end
23+
24+
require "rubygems"
25+
require "bundler/setup"
26+
27+
load Gem.bin_path("openbox", "openbox")

config/environments/development.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@
6161
# authentication: Settings.smtp.authentication,
6262
# enable_starttls_auto: Settings.smtp.enable_starttls_auto
6363
# }
64+
config.active_job.queue_adapter = :async
6465
end

config/environments/production.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
# config.active_job.queue_adapter = :resque
5959
# config.active_job.queue_name_prefix = "daikichi_#{Rails.env}"
6060
config.action_mailer.perform_caching = false
61+
config.active_job.queue_adapter = :good_job
6162

6263
# Ignore bad email addresses and do not raise email delivery errors.
6364
# Set this to true and configure the email server for immediate delivery to raise delivery errors.

config/environments/test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# your test database is "scratch space" for the test suite and is wiped
77
# and recreated between test runs. Don't rely on the data there!
88
config.cache_classes = true
9+
config.active_job.queue_adapter = :test
910

1011
# Do not eager load code on boot. This avoids loading your whole application
1112
# just for the purpose of running a single test. If you are using a tool that

0 commit comments

Comments
 (0)