middleware_healthcheck 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +48 -0
  5. data/Dockerfile +14 -0
  6. data/Gemfile +21 -0
  7. data/Gemfile.lock +167 -0
  8. data/LICENSE +0 -0
  9. data/README.md +6 -1
  10. data/Rakefile +2 -6
  11. data/lib/middleware_healthcheck.rb +8 -6
  12. data/lib/middleware_healthcheck/configuration.rb +10 -8
  13. data/lib/middleware_healthcheck/default_checkers.rb +3 -3
  14. data/lib/middleware_healthcheck/default_checkers/active_record_checker.rb +6 -5
  15. data/lib/middleware_healthcheck/main_checker.rb +9 -6
  16. data/lib/middleware_healthcheck/middleware.rb +3 -1
  17. data/lib/middleware_healthcheck/rails.rb +3 -1
  18. data/lib/middleware_healthcheck/version.rb +3 -1
  19. data/spec/dummy/Rakefile +8 -0
  20. data/spec/dummy/app/assets/config/manifest.js +4 -0
  21. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  22. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  23. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  24. data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
  25. data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
  26. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  27. data/spec/dummy/app/controllers/home_controller.rb +5 -0
  28. data/spec/dummy/app/helpers/application_helper.rb +4 -0
  29. data/spec/dummy/app/jobs/application_job.rb +4 -0
  30. data/spec/dummy/app/mailers/application_mailer.rb +6 -0
  31. data/spec/dummy/app/models/application_record.rb +5 -0
  32. data/spec/dummy/app/views/home/show.html.erb +1 -0
  33. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  34. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  35. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  36. data/spec/dummy/bin/bundle +5 -0
  37. data/spec/dummy/bin/rails +6 -0
  38. data/spec/dummy/bin/rake +6 -0
  39. data/spec/dummy/bin/setup +36 -0
  40. data/spec/dummy/bin/update +31 -0
  41. data/spec/dummy/config.ru +7 -0
  42. data/spec/dummy/config/application.rb +24 -0
  43. data/spec/dummy/config/boot.rb +7 -0
  44. data/spec/dummy/config/cable.yml +9 -0
  45. data/spec/dummy/config/database.yml +25 -0
  46. data/spec/dummy/config/environment.rb +7 -0
  47. data/spec/dummy/config/environments/development.rb +56 -0
  48. data/spec/dummy/config/environments/production.rb +88 -0
  49. data/spec/dummy/config/environments/test.rb +44 -0
  50. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  51. data/spec/dummy/config/initializers/assets.rb +13 -0
  52. data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
  53. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  54. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  55. data/spec/dummy/config/initializers/inflections.rb +18 -0
  56. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  57. data/spec/dummy/config/initializers/new_framework_defaults.rb +26 -0
  58. data/spec/dummy/config/initializers/session_store.rb +5 -0
  59. data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
  60. data/spec/dummy/config/locales/en.yml +23 -0
  61. data/spec/dummy/config/puma.rb +49 -0
  62. data/spec/dummy/config/routes.rb +5 -0
  63. data/spec/dummy/config/secrets.yml +22 -0
  64. data/spec/dummy/config/spring.rb +8 -0
  65. data/spec/dummy/db/test.sqlite3 +0 -0
  66. data/spec/dummy/log/test.log +80 -0
  67. data/spec/dummy/public/404.html +67 -0
  68. data/spec/dummy/public/422.html +67 -0
  69. data/spec/dummy/public/500.html +66 -0
  70. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  71. data/spec/dummy/public/apple-touch-icon.png +0 -0
  72. data/spec/dummy/public/favicon.ico +0 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1Z/1ZqiErdTkUSevJyliQcE6Uv0PPfRzU66d94xoZ3dSfw.cache +1 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7w/7w6Uz6xnLkTSMI9uPVNZTvew3_SuE2eFtCp2AMFxQeE.cache +1 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Cc/CcEKUCZOP7lJ_9fy6W8fGxHeo_pLX0_lh0F7JlaDl5I.cache +0 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/D_/D_apOMXJIIn679o4LoHlmz-NyTG64xuWe4ro7TKyzpU.cache +1 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/G0/G0qRtrgh65rOsfS-37uSF2UQdaiDRjEmjqhbpW0pBJA.cache +0 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/GD/GDi3vpM2thf3K_zCKYCjKfpt48sxKHSiGGGpyPoOmfw.cache +3 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/H8/H8v7a_YYGdXSKky0FMxhQ8ym_KD2BX6oGxi3jjzxFSg.cache +1 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Iw/IwkARxo4EFYR8P7KFYOqyI2hltfnkf4RBi2GUjeEltU.cache +1 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Jh/Jhvq9MvG2JctlJCzxUeOKtKWOu-CErXP0g6EYcMi8pk.cache +0 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/K2/K2fQCerqynseUF9eeLrwQyQhjV_SJOnR35ahxOQOH4Y.cache +1 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ls/LsCysQmA8eOxqOj2xfTI5HT0hmFxkgb9T-79Vfpkphk.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Nq/NqQL4uxBADGd-m9HPI6owT0X79j5Ih03H3Tj1zUv0fc.cache +1 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/RN/RN_c4-q-QAwblsfNBzf70NZ91k0xUW5abQ85cDmIFZ8.cache +1 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/T_/T_SzItfIMNw-VpC5cTm_V-MwdXicKcejykRA_eZGBcg.cache +0 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VQ/VQUXuiYfRkz_txe0ySlqGpjumXvwUZs4UQ3LdhtnLqo.cache +2 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Zg/ZguUWQxNrtIUWwdZcTog89HWZjwlg1b4B10YtdmGYxo.cache +1 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/b_/b_Itlk9QZZd7Rvf8kcA4yLP1R5Acu7jB-m1xQiSU0qE.cache +2 -0
  90. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dC/dCU95oHfJgwqhciDDqBRfdPqRoYltk9RsJijdjFJDFs.cache +0 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dt/dtA0dxun-aGWHDbilfOw6VkR_pXBQ6Hclrh-DQvu-E4.cache +1 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gg/ggjn9TAGF7zuNOkhChHWmsgBW1JVopRz-Y2hMUg7810.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gy/gyVskbQyIOYyz_cK-QTT4kgiBOAsnZC9gN84kLLDYdE.cache +1 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l_/l__yndgwOVdnrXF0F2Y92la2fbJ-bY8flE0NFs12AGY.cache +1 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mX/mX1nlsL_SWOB4y22W5FheRX0YEONKyOY7xUeIvRiHco.cache +2 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/p7/p7shbLzQVrz5OW2TM-TaNcMg8gsq9aZWwa93dkSMTQY.cache +1 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/rJ/rJkoK89nBrho66t78LEv5znjqvofPuVMzAQMTuQbVBg.cache +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wD/wD6mw4ORb1J88B71fVPpf5RbRJ3TVgfnA77wJFO8xj4.cache +1 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7PYh8DJvPykcEqpVab2vcY9-GFz-3cqtoMlRAu94Uc.cache +2 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y_/y_wGqfMY79V5Y8Hzbzuc2ChuexYsrFvBkUfKNuMyTQI.cache +0 -0
  103. data/spec/rails_helper.rb +60 -0
  104. data/spec/requests/healthcheck_spec.rb +46 -0
  105. data/spec/spec_helper.rb +99 -0
  106. metadata +198 -22
  107. data/lib/tasks/middleware_healthcheck_tasks.rake +0 -4
@@ -1,17 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MiddlewareHealthcheck
2
4
  class Configuration
3
- DEFAULT_HEALTHCHECK_PATH = '/healthcheck'.freeze
4
- DEFAULT_FULL_CHECK_PARAM_NAME = 'full'.freeze
5
- DEFAULT_SELECTED_CHECK_PARAM_NAME = 'checks'.freeze
5
+ DEFAULT_HEALTHCHECK_PATH = '/healthcheck'
6
+ DEFAULT_FULL_CHECK_PARAM_NAME = 'full'
7
+ DEFAULT_SELECTED_CHECK_PARAM_NAME = 'checks'
6
8
  DEFAULT_ERROR_RESPONSE_STATUS = 422
7
9
  DEFAULT_SUCCESS_RESPONSE_STATUS = 200
8
- DEFAULT_SUCCESS_RESPONSE_BODY = "It's alive!".freeze
9
- DEFAULT_ERRORS_DELIMITER = '; '.freeze
10
- DEFAULT_SELECTED_CHECK_PARAM_SPLIT_DELIMITER = ','.freeze
10
+ DEFAULT_SUCCESS_RESPONSE_BODY = "It's alive!"
11
+ DEFAULT_ERRORS_DELIMITER = '; '
12
+ DEFAULT_SELECTED_CHECK_PARAM_SPLIT_DELIMITER = ','
11
13
 
12
14
  attr_accessor :healthcheck_path, :full_check_param_name, :selected_check_param_name,
13
- :error_response_status, :success_response_status, :success_response_body,
14
- :errors_delimiter, :selected_check_param_split_delimiter, :checkers
15
+ :error_response_status, :success_response_status, :success_response_body,
16
+ :errors_delimiter, :selected_check_param_split_delimiter, :checkers
15
17
 
16
18
  def initialize
17
19
  self.healthcheck_path = DEFAULT_HEALTHCHECK_PATH
@@ -1,6 +1,6 @@
1
- if defined? ActiveRecord::Railtie
2
- require "middleware_healthcheck/default_checkers/active_record_checker"
3
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'middleware_healthcheck/default_checkers/active_record_checker' if defined? ActiveRecord::Railtie
4
4
 
5
5
  module MiddlewareHealthcheck
6
6
  module DefaultCheckers
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MiddlewareHealthcheck
2
4
  module DefaultCheckers
3
5
  class ActiveRecordChecker
4
- NOT_CONNECTED_ERROR = "Can't connect to database.".freeze
6
+ NOT_CONNECTED_ERROR = "Can't connect to database."
5
7
  EXCEPTION_REGEXP = /^ActiveRecord::/.freeze
6
8
 
7
9
  attr_accessor :error
8
10
 
9
- def initialize(_app, _env)
10
- end
11
+ def initialize(_app, _env); end
11
12
 
12
13
  def healthy?
13
14
  ActiveRecord::Base.establish_connection
@@ -18,8 +19,8 @@ module MiddlewareHealthcheck
18
19
  self.error = NOT_CONNECTED_ERROR
19
20
  false
20
21
  end
21
- rescue => e
22
- if e.class.to_s.match EXCEPTION_REGEXP
22
+ rescue StandardError => e
23
+ if e.class.to_s.match? EXCEPTION_REGEXP # rubocop:disable Style/GuardClause
23
24
  self.error = e.message
24
25
  false
25
26
  else
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MiddlewareHealthcheck
2
4
  class MainChecker
3
- QUERY_STRING_KEY = "QUERY_STRING".freeze
4
- UNDEFINED_CHECKER_ERROR = "Can't find checker: ".freeze
5
+ QUERY_STRING_KEY = 'QUERY_STRING'
6
+ UNDEFINED_CHECKER_ERROR = "Can't find checker: "
5
7
 
6
8
  attr_accessor :app, :env
7
9
 
@@ -31,7 +33,7 @@ module MiddlewareHealthcheck
31
33
  def build_success_response
32
34
  build_text_response(
33
35
  configuration.success_response_status,
34
- configuration.success_response_body
36
+ configuration.success_response_body
35
37
  )
36
38
  end
37
39
 
@@ -43,7 +45,7 @@ module MiddlewareHealthcheck
43
45
  end
44
46
 
45
47
  def build_text_response(status, body)
46
- [ status, { "Content-Type" => "text/plain" }, [body] ]
48
+ [status, { 'Content-Type' => 'text/plain' }, [body]]
47
49
  end
48
50
 
49
51
  def run_all_checkers
@@ -54,7 +56,6 @@ module MiddlewareHealthcheck
54
56
  run_checkers(selected_checkers)
55
57
  end
56
58
 
57
-
58
59
  def run_checkers(checkers)
59
60
  checkers.each do |checker|
60
61
  checker_instance = checker.new(@app, @env)
@@ -77,7 +78,8 @@ module MiddlewareHealthcheck
77
78
  end
78
79
 
79
80
  def selected_checkers_names
80
- @selected_check_param_names ||= params[configuration.selected_check_param_name]
81
+ @selected_checkers_names ||=
82
+ params[configuration.selected_check_param_name]
81
83
  .split(configuration.selected_check_param_split_delimiter)
82
84
  end
83
85
 
@@ -92,6 +94,7 @@ module MiddlewareHealthcheck
92
94
  def full_check?
93
95
  params[configuration.full_check_param_name].present?
94
96
  end
97
+
95
98
  def selected_check?
96
99
  params[configuration.selected_check_param_name].present?
97
100
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MiddlewareHealthcheck
2
4
  class Middleware
3
- PATH_INFO_KEY = "PATH_INFO".freeze
5
+ PATH_INFO_KEY = 'PATH_INFO'
4
6
 
5
7
  def initialize(app)
6
8
  @app = app
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MiddlewareHealthcheck
2
4
  class Railtie < Rails::Railtie
3
- initializer "middleware_healthcheck.configure_rails_initialization" do
5
+ initializer 'middleware_healthcheck.configure_rails_initialization' do
4
6
  app.middleware.insert_after Rails::Rack::Logger, MiddlewareHealthcheck::Middleware
5
7
  end
6
8
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MiddlewareHealthcheck
2
- VERSION = '0.2.2'
4
+ VERSION = '1.0.0'
3
5
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative 'config/application'
7
+
8
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Channel < ActionCable::Channel::Base
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Connection < ActionCable::Connection::Base
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class HomeController < ApplicationController
4
+ def show; end
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
@@ -0,0 +1 @@
1
+ <h1>Home</h1>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+
7
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9
+ </head>
10
+
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
5
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require_relative '../config/boot'
6
+ require 'rails/commands'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../config/boot'
5
+ require 'rake'
6
+ Rake.application.run
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ # path to your application root.
9
+ APP_ROOT = Pathname.new File.expand_path('..', __dir__)
10
+
11
+ def system!(*args)
12
+ system(*args) || abort("\n== Command #{args} failed ==")
13
+ end
14
+
15
+ chdir APP_ROOT do
16
+ # This script is a starting point to setup your application.
17
+ # Add necessary setup steps to this file.
18
+
19
+ puts '== Installing dependencies =='
20
+ system! 'gem install bundler --conservative'
21
+ system('bundle check') || system!('bundle install')
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:setup'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ # path to your application root.
9
+ APP_ROOT = Pathname.new File.expand_path('..', __dir__)
10
+
11
+ def system!(*args)
12
+ system(*args) || abort("\n== Command #{args} failed ==")
13
+ end
14
+
15
+ chdir APP_ROOT do
16
+ # This script is a way to update your development environment automatically.
17
+ # Add necessary update steps to this file.
18
+
19
+ puts '== Installing dependencies =='
20
+ system! 'gem install bundler --conservative'
21
+ system('bundle check') || system!('bundle install')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require_relative 'config/environment'
6
+
7
+ run Rails.application
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'boot'
4
+
5
+ # Pick the frameworks you want:
6
+ require 'active_record/railtie'
7
+ require 'action_controller/railtie'
8
+ require 'action_view/railtie'
9
+ require 'action_mailer/railtie'
10
+ require 'active_job/railtie'
11
+ require 'action_cable/engine'
12
+ # require "rails/test_unit/railtie"
13
+ require 'sprockets/railtie'
14
+
15
+ Bundler.require(*Rails.groups)
16
+ require 'middleware_healthcheck'
17
+
18
+ module Dummy
19
+ class Application < Rails::Application
20
+ # Settings in config/environments/* take precedence over those specified here.
21
+ # Application configuration should go into files in config/initializers
22
+ # -- all .rb files in that directory are automatically loaded.
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
5
+
6
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
7
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)