├── .gitignore ├── LICENSE.txt ├── README.md ├── client ├── .gitignore ├── .rrrspec ├── .rspec ├── Gemfile ├── Gemfile.lock └── spec │ ├── samples │ ├── fail_spec.rb │ ├── success_spec.rb │ └── timeout_spec.rb │ └── spec_helper.rb ├── demo ├── .foreman ├── .gitignore ├── Procfile └── setup.rb └── server ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── Rakefile ├── bin └── console ├── config.ru ├── config ├── database.yml ├── master.rb ├── redis.rb └── worker.rb └── tmp ├── pids └── .keep └── rrrspec-rsync └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/47b1ace3d0b71722ea93be14f42846ab3329f161/Global/OSX.gitignore 2 | 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must end with two \r 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear on external disk 14 | .Spotlight-V100 15 | .Trashes 16 | 17 | # Directories potentially created on remote AFP share 18 | .AppleDB 19 | .AppleDesktop 20 | Network Trash Folder 21 | Temporary Items 22 | .apdisk 23 | 24 | 25 | .ruby-version 26 | .rbenv-gemsets 27 | 28 | 29 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Yuichi Goto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rrrspec-tutorial 2 | Learn how to set up [RRRSpec](https://github.com/cookpad/rrrspec). 3 | NOTE: This tutorial is written for [the August 2016 issue of Software Design](http://gihyo.jp/magazine/SD/archive/2016/201608) 4 | published by Gijutsu-Hyohron Co., Ltd. 5 | 6 | ## Tutorial 7 | Proceed with the following steps: 8 | 9 | 1. [Setup Client](https://github.com/yasaichi/rrrspec-tutorial/compare/69c396706640f8afe9cfd24c54875cb119020547...setup-client) 10 | 2. [Setup Master and Web UI](https://github.com/yasaichi/rrrspec-tutorial/compare/setup-client...setup-master-and-web) 11 | 3. [Setup Worker](https://github.com/yasaichi/rrrspec-tutorial/compare/setup-master-and-web...setup-worker) 12 | 4. [Test run](https://github.com/yasaichi/rrrspec-tutorial/compare/setup-worker...test-run) 13 | 14 | ## Structure 15 | * `client`: Client application 16 | * `server`: For Master (+ Web UI) and Worker 17 | * `demo`: For demonstration 18 | 19 | ## For the impatient 20 | 21 | ### Setup 22 | Clone the repository with: 23 | 24 | ``` 25 | git clone git@github.com:yasaichi/rrrspec-tutorial.git 26 | ``` 27 | 28 | Run a "magical" script with: 29 | 30 | ``` 31 | ruby demo/setup.rb 32 | ``` 33 | 34 | ### Test run 35 | Start the server with: 36 | 37 | ``` 38 | cd demo && foreman start 39 | ``` 40 | 41 | Create a new taskset with: 42 | 43 | ``` 44 | cd client && foreman run --env=../demo/.env bundle exec rrrspec-client start --rsync-name=sample_app 45 | ``` 46 | 47 | Open the following URL in your browser to check the status: 48 | 49 | ``` 50 | http://localhost:3000 51 | ``` 52 | 53 | ## License 54 | Copyright (c) 2016 Yuichi Goto. See [LICENSE.txt](LICENSE.txt) for further details. 55 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | dump.rdb 2 | 3 | 4 | -------------------------------------------------------------------------------- /client/.rrrspec: -------------------------------------------------------------------------------- 1 | RRRSpec.configure do |config| 2 | config.redis = { 3 | host: ENV["RRRSPEC_REDIS_HOST"], 4 | port: 6379 5 | } 6 | end 7 | 8 | RRRSpec.configure(:client) do |config| 9 | Time.zone_default = Time.find_zone("Asia/Tokyo") 10 | 11 | config.packaging_dir = File.expand_path("..", __FILE__) 12 | config.rsync_remote_path = ENV["RRRSPEC_RSYNC_REMOTE_PATH"] 13 | config.rsync_options = %w( 14 | --compress 15 | --times 16 | --recursive 17 | --links 18 | --perms 19 | --inplace 20 | --delete 21 | --cvs-exclude 22 | ).join(" ") 23 | 24 | config.spec_files = lambda do 25 | Dir.chdir(config.packaging_dir) do 26 | Dir["spec/**{,/*/**}/*_spec.rb"].uniq 27 | end 28 | end 29 | 30 | config.setup_command = <<-SETUP 31 | bundle install 32 | SETUP 33 | 34 | config.slave_command = <<-SLAVE 35 | bundle exec rrrspec-client slave 36 | SLAVE 37 | 38 | config.taskset_class = File.basename(config.packaging_dir) 39 | config.worker_type = "default" 40 | config.max_workers = 10 41 | config.max_trials = 1 42 | config.unknown_spec_timeout_sec = 90 43 | config.least_timeout_sec = 60 44 | end 45 | -------------------------------------------------------------------------------- /client/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /client/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "rspec" 4 | gem "rrrspec-client", "0.4.3" 5 | -------------------------------------------------------------------------------- /client/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | activesupport (4.2.6) 5 | i18n (~> 0.7) 6 | json (~> 1.7, >= 1.7.7) 7 | minitest (~> 5.1) 8 | thread_safe (~> 0.3, >= 0.3.4) 9 | tzinfo (~> 1.1) 10 | addressable (2.4.0) 11 | diff-lcs (1.2.5) 12 | extreme_timeout (0.3.1) 13 | i18n (0.7.0) 14 | json (1.8.3) 15 | launchy (2.4.3) 16 | addressable (~> 2.3) 17 | minitest (5.9.0) 18 | redis (3.3.0) 19 | rrrspec-client (0.4.3) 20 | activesupport 21 | extreme_timeout 22 | launchy 23 | redis 24 | rspec (>= 3.0) 25 | thor (>= 0.18.0) 26 | tzinfo 27 | uuidtools 28 | rspec (3.4.0) 29 | rspec-core (~> 3.4.0) 30 | rspec-expectations (~> 3.4.0) 31 | rspec-mocks (~> 3.4.0) 32 | rspec-core (3.4.4) 33 | rspec-support (~> 3.4.0) 34 | rspec-expectations (3.4.0) 35 | diff-lcs (>= 1.2.0, < 2.0) 36 | rspec-support (~> 3.4.0) 37 | rspec-mocks (3.4.1) 38 | diff-lcs (>= 1.2.0, < 2.0) 39 | rspec-support (~> 3.4.0) 40 | rspec-support (3.4.1) 41 | thor (0.19.1) 42 | thread_safe (0.3.5) 43 | tzinfo (1.2.2) 44 | thread_safe (~> 0.1) 45 | uuidtools (2.1.5) 46 | 47 | PLATFORMS 48 | ruby 49 | 50 | DEPENDENCIES 51 | rrrspec-client (= 0.4.3) 52 | rspec 53 | 54 | BUNDLED WITH 55 | 1.12.4 56 | -------------------------------------------------------------------------------- /client/spec/samples/fail_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe "test2" do 2 | it "will be failed" do 3 | fail 4 | end 5 | 6 | it "will be succeeded" do 7 | expect(1).to eq(1) 8 | end 9 | 10 | it "will be pending" do 11 | pending 12 | expect(1).to eq(2) 13 | end 14 | 15 | it "will be skipped" do 16 | skip 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /client/spec/samples/success_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe "test1" do 2 | it "will be succeeded" do 3 | expect(1).to eq(1) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /client/spec/samples/timeout_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe "test3" do 2 | it "will be timeout" do 3 | sleep 4 | fail 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /client/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rspec --init` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # The `.rspec` file also contains a few flags that are not defaults but that 16 | # users commonly want. 17 | # 18 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 19 | RSpec.configure do |config| 20 | # rspec-expectations config goes here. You can use an alternate 21 | # assertion/expectation library such as wrong or the stdlib/minitest 22 | # assertions if you prefer. 23 | config.expect_with :rspec do |expectations| 24 | # This option will default to `true` in RSpec 4. It makes the `description` 25 | # and `failure_message` of custom matchers include text for helper methods 26 | # defined using `chain`, e.g.: 27 | # be_bigger_than(2).and_smaller_than(4).description 28 | # # => "be bigger than 2 and smaller than 4" 29 | # ...rather than: 30 | # # => "be bigger than 2" 31 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 32 | end 33 | 34 | # rspec-mocks config goes here. You can use an alternate test double 35 | # library (such as bogus or mocha) by changing the `mock_with` option here. 36 | config.mock_with :rspec do |mocks| 37 | # Prevents you from mocking or stubbing a method that does not exist on 38 | # a real object. This is generally recommended, and will default to 39 | # `true` in RSpec 4. 40 | mocks.verify_partial_doubles = true 41 | end 42 | 43 | # The settings below are suggested to provide a good initial experience 44 | # with RSpec, but feel free to customize to your heart's content. 45 | =begin 46 | # These two settings work together to allow you to limit a spec run 47 | # to individual examples or groups you care about by tagging them with 48 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples 49 | # get run. 50 | config.filter_run :focus 51 | config.run_all_when_everything_filtered = true 52 | 53 | # Allows RSpec to persist some state between runs in order to support 54 | # the `--only-failures` and `--next-failure` CLI options. We recommend 55 | # you configure your source control system to ignore this file. 56 | config.example_status_persistence_file_path = "spec/examples.txt" 57 | 58 | # Limits the available syntax to the non-monkey patched syntax that is 59 | # recommended. For more details, see: 60 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 61 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 62 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 63 | config.disable_monkey_patching! 64 | 65 | # This setting enables warnings. It's recommended, but in some cases may 66 | # be too noisy due to issues in dependencies. 67 | config.warnings = true 68 | 69 | # Many RSpec users commonly either run the entire suite or an individual 70 | # file, and it's useful to allow more verbose output when running an 71 | # individual spec file. 72 | if config.files_to_run.one? 73 | # Use the documentation formatter for detailed output, 74 | # unless a formatter has already been configured 75 | # (e.g. via a command-line flag). 76 | config.default_formatter = 'doc' 77 | end 78 | 79 | # Print the 10 slowest examples and example groups at the 80 | # end of the spec run, to help surface which specs are running 81 | # particularly slow. 82 | config.profile_examples = 10 83 | 84 | # Run specs in random order to surface order dependencies. If you find an 85 | # order dependency and want to debug it, you can fix the order by providing 86 | # the seed, which is printed after each run. 87 | # --seed 1234 88 | config.order = :random 89 | 90 | # Seed global randomization in this process using the `--seed` CLI option. 91 | # Setting this allows you to use `--seed` to deterministically reproduce 92 | # test failures related to randomization by passing the same `--seed` value 93 | # as the one that triggered the failure. 94 | Kernel.srand config.seed 95 | =end 96 | end 97 | -------------------------------------------------------------------------------- /demo/.foreman: -------------------------------------------------------------------------------- 1 | env: .env 2 | port: 3000 3 | procfile: Procfile 4 | root: ../server 5 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /demo/Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec unicorn -p $PORT 2 | redis: redis-server 3 | server: bundle exec rrrspec-server server --config config/master.rb --no-daemonize 4 | worker: bundle exec rrrspec-server worker --config config/worker.rb --no-daemonize 5 | -------------------------------------------------------------------------------- /demo/setup.rb: -------------------------------------------------------------------------------- 1 | require "open3" 2 | require "pathname" 3 | 4 | def execute(command) 5 | length = command.split("\n").map(&:length).max 6 | puts ["=" * length, command, "=" * length] 7 | 8 | Open3.popen3(command) do |stdin, stdout| 9 | stdin.close 10 | stdout.each { |line| puts line } 11 | end 12 | end 13 | 14 | roots = { project: Pathname.new("../../").expand_path(__FILE__) } 15 | %i(client demo server).each { |dirname| roots[dirname] = roots[:project].join(dirname.to_s) } 16 | 17 | # Install libraries 18 | execute < 1.6) 9 | rack-test (~> 0.6.2) 10 | rails-dom-testing (~> 1.0, >= 1.0.5) 11 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 12 | actionview (4.2.6) 13 | activesupport (= 4.2.6) 14 | builder (~> 3.1) 15 | erubis (~> 2.7.0) 16 | rails-dom-testing (~> 1.0, >= 1.0.5) 17 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 18 | activemodel (4.2.6) 19 | activesupport (= 4.2.6) 20 | builder (~> 3.1) 21 | activerecord (4.2.6) 22 | activemodel (= 4.2.6) 23 | activesupport (= 4.2.6) 24 | arel (~> 6.0) 25 | activerecord-import (0.14.1) 26 | activerecord (>= 3.2) 27 | activesupport (4.2.6) 28 | i18n (~> 0.7) 29 | json (~> 1.7, >= 1.7.7) 30 | minitest (~> 5.1) 31 | thread_safe (~> 0.3, >= 0.3.4) 32 | tzinfo (~> 1.1) 33 | addressable (2.4.0) 34 | api-pagination (3.1.0) 35 | arel (6.0.3) 36 | autoprefixer-rails (6.3.6.2) 37 | execjs 38 | axiom-types (0.1.1) 39 | descendants_tracker (~> 0.0.4) 40 | ice_nine (~> 0.11.0) 41 | thread_safe (~> 0.3, >= 0.3.1) 42 | bootstrap-sass (3.3.6) 43 | autoprefixer-rails (>= 5.2.1) 44 | sass (>= 3.3.4) 45 | builder (3.2.2) 46 | coderay (1.1.1) 47 | coercible (1.0.0) 48 | descendants_tracker (~> 0.0.1) 49 | coffee-script (2.2.0) 50 | coffee-script-source 51 | execjs 52 | coffee-script-source (1.10.0) 53 | coolline (0.5.0) 54 | unicode_utils (~> 1.4) 55 | descendants_tracker (0.0.4) 56 | thread_safe (~> 0.3, >= 0.3.1) 57 | diff-lcs (1.2.5) 58 | equalizer (0.0.11) 59 | erubis (2.7.0) 60 | execjs (2.7.0) 61 | extreme_timeout (0.3.1) 62 | facter (2.4.6) 63 | CFPropertyList (~> 2.2.6) 64 | grape (0.9.0) 65 | activesupport 66 | builder 67 | hashie (>= 2.1.0) 68 | multi_json (>= 1.3.2) 69 | multi_xml (>= 0.5.2) 70 | rack (>= 1.3.0) 71 | rack-accept 72 | rack-mount 73 | virtus (>= 1.0.0) 74 | haml (4.0.7) 75 | tilt 76 | hashie (3.4.4) 77 | hike (1.2.3) 78 | i18n (0.7.0) 79 | ice_nine (0.11.2) 80 | json (1.8.3) 81 | kaminari (0.16.3) 82 | actionpack (>= 3.0.0) 83 | activesupport (>= 3.0.0) 84 | kgio (2.10.0) 85 | launchy (2.4.3) 86 | addressable (~> 2.3) 87 | loofah (2.0.3) 88 | nokogiri (>= 1.5.9) 89 | method_source (0.8.2) 90 | mini_portile2 (2.1.0) 91 | minitest (5.9.0) 92 | multi_json (1.12.1) 93 | multi_xml (0.5.5) 94 | mysql2 (0.4.4) 95 | nokogiri (1.6.8) 96 | mini_portile2 (~> 2.1.0) 97 | pkg-config (~> 1.1.7) 98 | oj (2.16.1) 99 | pkg-config (1.1.7) 100 | pry (0.10.3) 101 | coderay (~> 1.1.0) 102 | method_source (~> 0.8.1) 103 | slop (~> 3.4) 104 | pry-coolline (0.2.5) 105 | coolline (~> 0.5) 106 | rack (1.6.4) 107 | rack-accept (0.4.5) 108 | rack (>= 0.4) 109 | rack-mount (0.8.3) 110 | rack (>= 1.0.0) 111 | rack-protection (1.5.3) 112 | rack 113 | rack-test (0.6.3) 114 | rack (>= 1.0) 115 | rails-deprecated_sanitizer (1.0.3) 116 | activesupport (>= 4.2.0.alpha) 117 | rails-dom-testing (1.0.7) 118 | activesupport (>= 4.2.0.beta, < 5.0) 119 | nokogiri (~> 1.6.0) 120 | rails-deprecated_sanitizer (>= 1.0.1) 121 | rails-html-sanitizer (1.0.3) 122 | loofah (~> 2.0) 123 | raindrops (0.16.0) 124 | rake (11.2.2) 125 | redis (3.3.0) 126 | rrrspec-client (0.4.3) 127 | activesupport 128 | extreme_timeout 129 | launchy 130 | redis 131 | rspec (>= 3.0) 132 | thor (>= 0.18.0) 133 | tzinfo 134 | uuidtools 135 | rrrspec-server (0.4.3) 136 | activerecord (~> 4.2.0) 137 | activerecord-import (>= 0.7.0) 138 | activesupport 139 | bundler 140 | facter 141 | redis 142 | rrrspec-client 143 | thor (>= 0.18.0) 144 | rrrspec-web (0.4.3) 145 | activerecord (~> 4.2.0) 146 | activesupport 147 | api-pagination (< 3.2.0) 148 | bootstrap-sass (>= 3.2) 149 | coffee-script (~> 2.2.0) 150 | grape (~> 0.9.0) 151 | haml (~> 4.0.3) 152 | kaminari (~> 0.16.0) 153 | oj 154 | rrrspec-client 155 | rrrspec-server 156 | sass 157 | sinatra (~> 1.4.3) 158 | sinatra-asset-pipeline 159 | rspec (3.4.0) 160 | rspec-core (~> 3.4.0) 161 | rspec-expectations (~> 3.4.0) 162 | rspec-mocks (~> 3.4.0) 163 | rspec-core (3.4.4) 164 | rspec-support (~> 3.4.0) 165 | rspec-expectations (3.4.0) 166 | diff-lcs (>= 1.2.0, < 2.0) 167 | rspec-support (~> 3.4.0) 168 | rspec-mocks (3.4.1) 169 | diff-lcs (>= 1.2.0, < 2.0) 170 | rspec-support (~> 3.4.0) 171 | rspec-support (3.4.1) 172 | sass (3.4.22) 173 | sinatra (1.4.7) 174 | rack (~> 1.5) 175 | rack-protection (~> 1.4) 176 | tilt (>= 1.3, < 3) 177 | sinatra-asset-pipeline (0.5.0) 178 | coffee-script 179 | rake 180 | sass 181 | sinatra 182 | sprockets 183 | sprockets-helpers 184 | sprockets-sass 185 | slop (3.6.0) 186 | sprockets (2.12.4) 187 | hike (~> 1.2) 188 | multi_json (~> 1.0) 189 | rack (~> 1.0) 190 | tilt (~> 1.1, != 1.3.0) 191 | sprockets-helpers (1.2.1) 192 | sprockets (>= 2.2) 193 | sprockets-sass (1.3.1) 194 | sprockets (~> 2.0) 195 | tilt (~> 1.1) 196 | thor (0.19.1) 197 | thread_safe (0.3.5) 198 | tilt (1.4.1) 199 | tzinfo (1.2.2) 200 | thread_safe (~> 0.1) 201 | unicode_utils (1.4.0) 202 | unicorn (5.1.0) 203 | kgio (~> 2.6) 204 | raindrops (~> 0.7) 205 | uuidtools (2.1.5) 206 | virtus (1.0.5) 207 | axiom-types (~> 0.1) 208 | coercible (~> 1.0) 209 | descendants_tracker (~> 0.0, >= 0.0.3) 210 | equalizer (~> 0.0, >= 0.0.9) 211 | 212 | PLATFORMS 213 | ruby 214 | 215 | DEPENDENCIES 216 | mysql2 217 | pry 218 | pry-coolline 219 | rrrspec-server (= 0.4.3) 220 | rrrspec-web (= 0.4.3) 221 | unicorn 222 | 223 | BUNDLED WITH 224 | 1.12.4 225 | -------------------------------------------------------------------------------- /server/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | 3 | ENV["RACK_ENV"] = ENV["RRRSPEC_ENV"] 4 | ENV["RRRSPEC_CONFIG_FILES"] = File.expand_path("../config/master.rb", __FILE__) 5 | 6 | load "#{Gem::Specification.find_by_name('rrrspec-server').gem_dir}/tasks/db.rake" 7 | load "#{Gem::Specification.find_by_name('rrrspec-web').gem_dir}/tasks/assets.rake" 8 | -------------------------------------------------------------------------------- /server/bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "rrrspec/server" 5 | require "pry" 6 | 7 | config_files = [File.expand_path("../../config/master.rb", __FILE__)] 8 | RRRSpec.setup(RRRSpec::Server::ServerConfiguration.new, config_files) 9 | ActiveRecord::Base.establish_connection(**RRRSpec.configuration.persistence_db) 10 | 11 | Pry.start 12 | -------------------------------------------------------------------------------- /server/config.ru: -------------------------------------------------------------------------------- 1 | ENV["RACK_ENV"] = ENV["RRRSPEC_ENV"] 2 | 3 | require "bundler/setup" 4 | require "rrrspec/web" 5 | require_relative "config/master" 6 | 7 | RRRSpec::Web.setup 8 | run Rack::Cascade.new([RRRSpec::Web::APIv2, RRRSpec::Web::App]) 9 | -------------------------------------------------------------------------------- /server/config/database.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | adapter: mysql2 3 | encoding: utf8mb4 4 | charset: utf8mb4 5 | collation: utf8mb4_general_ci 6 | reconnect: false 7 | pool: 5 8 | 9 | development: 10 | <<: *default 11 | database: rrrspec_development 12 | username: root 13 | 14 | production: 15 | <<: *default 16 | host: <%= ENV["RRRSPEC_DATABASE_HOST"] %> 17 | database: <%= ENV["RRRSPEC_DATABASE_NAME"] %> 18 | username: <%= ENV["RRRSPEC_DATABASE_USERNAME"] %> 19 | password: <%= ENV["RRRSPEC_DATABASE_PASSWORD"] %> 20 | -------------------------------------------------------------------------------- /server/config/master.rb: -------------------------------------------------------------------------------- 1 | require_relative "redis" 2 | 3 | env = ENV["RRRSPEC_ENV"] || "development" 4 | root = Pathname.new("../..").expand_path(__FILE__) 5 | db_config = YAML.load(ERB.new(File.read(root.join("config/database.yml"))).result) 6 | 7 | ActiveRecord::Base.default_timezone = :local 8 | 9 | %i(server web).each do |type| 10 | RRRSpec.configure(type) do |config| 11 | config.persistence_db = db_config[env].symbolize_keys 12 | config.execute_log_text_path = root.join("tmp/rrrspec-log-texts") 13 | end 14 | end 15 | 16 | RRRSpec.configure(:server) do |config| 17 | config.pidfile = root.join("tmp/pids/rrrspec-master.pid") 18 | end 19 | -------------------------------------------------------------------------------- /server/config/redis.rb: -------------------------------------------------------------------------------- 1 | RRRSpec.configure do |config| 2 | config.redis = { 3 | host: ENV["RRRSPEC_REDIS_HOST"], 4 | port: 6379 5 | } 6 | end 7 | -------------------------------------------------------------------------------- /server/config/worker.rb: -------------------------------------------------------------------------------- 1 | require_relative "redis" 2 | 3 | root = Pathname.new("../..").expand_path(__FILE__) 4 | 5 | RRRSpec.configure(:worker) do |config| 6 | config.pidfile = root.join("tmp/pids/rrrspec-worker.pid") 7 | 8 | config.rsync_remote_path = ENV["RRRSPEC_RSYNC_REMOTE_PATH"] 9 | config.rsync_options = %w( 10 | --compress 11 | --times 12 | --recursive 13 | --links 14 | --perms 15 | --inplace 16 | --delete 17 | ).join(" ") 18 | 19 | config.working_dir = root.join("tmp/rrrspec-working").to_s 20 | config.worker_type = "default" 21 | end 22 | -------------------------------------------------------------------------------- /server/tmp/pids/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yasaichi/rrrspec-tutorial/8cf9cde8bdea5d2e214ad64378f6d968091dd7f1/server/tmp/pids/.keep -------------------------------------------------------------------------------- /server/tmp/rrrspec-rsync/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yasaichi/rrrspec-tutorial/8cf9cde8bdea5d2e214ad64378f6d968091dd7f1/server/tmp/rrrspec-rsync/.keep --------------------------------------------------------------------------------