tablexi_dev-generators 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +66 -0
- data/Rakefile +29 -0
- data/lib/generators/tablexi_dev/all_generator.rb +23 -0
- data/lib/generators/tablexi_dev/git_hook_generator/files/general-pre-commit +2 -0
- data/lib/generators/tablexi_dev/git_hook_generator/files/general-pre-push +2 -0
- data/lib/generators/tablexi_dev/git_hook_generator/files/rubocop-pre-commit +36 -0
- data/lib/generators/tablexi_dev/git_hook_generator/files/rubocop-pre-push +8 -0
- data/lib/generators/tablexi_dev/git_hook_generator.rb +39 -0
- data/lib/generators/tablexi_dev/rubocop_generator/files/dot_rubocop-project_overrides.yml +11 -0
- data/lib/generators/tablexi_dev/rubocop_generator/files/dot_rubocop-txi.yml +100 -0
- data/lib/generators/tablexi_dev/rubocop_generator/files/dot_rubocop.yml +15 -0
- data/lib/generators/tablexi_dev/rubocop_generator.rb +49 -0
- data/lib/generators/tablexi_dev/unicorn_generator/templates/production.rb.tt +36 -0
- data/lib/generators/tablexi_dev/unicorn_generator/templates/stage.rb.tt +36 -0
- data/lib/generators/tablexi_dev/unicorn_generator.rb +30 -0
- data/lib/tablexi_dev/generators/version.rb +11 -0
- data/lib/tablexi_dev/generators.rb +9 -0
- data/lib/tasks/tablexi_dev/generators_tasks.rake +5 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56152f0209f0fc9d78f53fc96e874842beb38b3c
|
4
|
+
data.tar.gz: 57e1da7ecb905db9a828752d0dc0c77f3addeea5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 59f41aac68253ffba890d70abf74568f6797156ff22163c0539afd8120d0e6cc1a8a75b7419d54c91e38f0067fa7b6e6c52c34d00604a2f9a9be591622764cdd
|
7
|
+
data.tar.gz: 0a41f308c023d0630fb1b38bf88222526f6ab6568eaf32d7b0f043262178d8f2b3f48680089d0dee51be98b70b5e97b64bedcea8d2c058a1fb815c50c29d488c
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Jason Hanggi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Table XI Dev Generators
|
2
|
+
|
3
|
+
A recommended set of generators for Table XI projects.
|
4
|
+
|
5
|
+
## Example usage
|
6
|
+
|
7
|
+
Install everything:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
bundle exec rails g tablexi_dev:all
|
11
|
+
```
|
12
|
+
|
13
|
+
Or install only the ones you want:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bundle exec rails g tablexi_dev:git_hook
|
17
|
+
bundle exec rails g tablexi_dev:rubocop
|
18
|
+
bundle exec rails g tablexi_dev:unicorn
|
19
|
+
# ...
|
20
|
+
```
|
21
|
+
|
22
|
+
## Installing this gem
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
group :development do
|
28
|
+
gem "tablexi_dev-generators"
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
And then execute:
|
33
|
+
```bash
|
34
|
+
$ bundle
|
35
|
+
```
|
36
|
+
|
37
|
+
## Upgrading this gem
|
38
|
+
|
39
|
+
After upgrading this gem, it's recommended that you re-run the generators and verify that the changed files are correct.
|
40
|
+
|
41
|
+
## All available generators
|
42
|
+
|
43
|
+
### Generator: Git hooks
|
44
|
+
|
45
|
+
bundle exec rails g tablexi_dev:git_hook
|
46
|
+
|
47
|
+
This generator will guide you through installing git hooks. If you do not have a strong preference, we recommend installing the `pre-push` rubocop hook.
|
48
|
+
|
49
|
+
Because git hooks do not get checked into the remote repository, it's recommended that each team member run this generator upon installing any project on their local machine.
|
50
|
+
|
51
|
+
### Generator: Rubocop
|
52
|
+
|
53
|
+
bundle exec rails g tablexi_dev:rubocop
|
54
|
+
|
55
|
+
The rubocop generator is designed to be used in the following different situations:
|
56
|
+
|
57
|
+
1) On initial setup of rubocop in a project, to set up the tool.
|
58
|
+
2) When updates to the rubocop cops occur (new versions of [Rubocop](https://github.com/bbatsov/rubocop/) are provided, with new rules)
|
59
|
+
|
60
|
+
For detailed instructions on the rubocop generator and its options, [check out the rubocop readme](rubocop.md)
|
61
|
+
|
62
|
+
### Generator: Unicorn
|
63
|
+
|
64
|
+
bundle exec rails g tablexi_dev:rubocop
|
65
|
+
|
66
|
+
The unicorn generator sets up a project's unicorn configuration files.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "bundler/setup"
|
5
|
+
rescue LoadError
|
6
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
7
|
+
end
|
8
|
+
|
9
|
+
require "rdoc/task"
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = "rdoc"
|
13
|
+
rdoc.title = "TablexiDev::Generators"
|
14
|
+
rdoc.options << "--line-numbers"
|
15
|
+
rdoc.rdoc_files.include("README.md")
|
16
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
require "bundler/gem_tasks"
|
20
|
+
|
21
|
+
require "rake/testtask"
|
22
|
+
|
23
|
+
Rake::TestTask.new(:test) do |t|
|
24
|
+
t.libs << "test"
|
25
|
+
t.pattern = "test/**/*_test.rb"
|
26
|
+
t.verbose = false
|
27
|
+
end
|
28
|
+
|
29
|
+
task default: :test
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TablexiDev
|
4
|
+
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class AllGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
GENERATORS = %i[
|
10
|
+
git_hook
|
11
|
+
rubocop
|
12
|
+
unicorn
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
def generate_all
|
16
|
+
GENERATORS.each { |generator| generate "tablexi_dev:#{generator}" }
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "rubocop"
|
5
|
+
|
6
|
+
ADDED_OR_MODIFIED = /A|AM|^M/
|
7
|
+
|
8
|
+
# to prevent code injection: system is a dangerous call
|
9
|
+
def raise_single_quote_error
|
10
|
+
raise ArgumentError, "Single quotes are not allowed in filenames here."
|
11
|
+
end
|
12
|
+
|
13
|
+
def extract_file_name(file_name_with_status)
|
14
|
+
file_name_array = file_name_with_status.strip.split(" ")
|
15
|
+
file_name_array.shift
|
16
|
+
fname = file_name_array.join(" ")
|
17
|
+
fname[0] = "" if fname[0] == '"'
|
18
|
+
fname[fname.length - 1] = "" if fname[fname.length - 1] == '"'
|
19
|
+
raise_single_quote_error if fname.include?("'")
|
20
|
+
fname
|
21
|
+
end
|
22
|
+
|
23
|
+
changed_files =
|
24
|
+
`git status --porcelain`
|
25
|
+
.split(/\n/)
|
26
|
+
.select { |file_name_with_status| file_name_with_status =~ ADDED_OR_MODIFIED }
|
27
|
+
.map { |file_name_with_status| extract_file_name file_name_with_status }
|
28
|
+
.select { |file_name| File.extname(file_name) =~ /.rb/ }
|
29
|
+
.join("' '")
|
30
|
+
|
31
|
+
unless changed_files.empty?
|
32
|
+
system("bundle exec rubocop -a --force-exclusion '#{changed_files}'")
|
33
|
+
system("git add '#{changed_files}'")
|
34
|
+
end
|
35
|
+
|
36
|
+
exit $CHILD_STATUS.to_s[-1].to_i
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# We choose not to auto-correct so that the return code is non-0
|
4
|
+
# causing the pre-push to prevent the 'git push' from doing it.
|
5
|
+
# This will run Rubocop on all files tracked with git, ignoring any files in the
|
6
|
+
# repo's .gitignore or your .gitignore_global.
|
7
|
+
|
8
|
+
bundle exec rubocop --force-exclusion `git ls-tree -r HEAD --name-only`
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TablexiDev
|
4
|
+
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class GitHookGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path("../git_hook_generator/files/", __FILE__)
|
10
|
+
|
11
|
+
def copy_files
|
12
|
+
maybe_install_rubocop_hook_pre "push"
|
13
|
+
maybe_install_rubocop_hook_pre "commit"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def maybe_install_rubocop_hook_pre(type)
|
19
|
+
return unless yes?("Would you like to automatically run rubocop before each 'git #{type}'?")
|
20
|
+
|
21
|
+
# Define pre-hook file paths
|
22
|
+
rubocop_path = ".git/hooks/rubocop-pre-#{type}"
|
23
|
+
general_path = ".git/hooks/pre-#{type}"
|
24
|
+
|
25
|
+
# Copy files from this generator into the project
|
26
|
+
copy_and_set_executable("rubocop-pre-#{type}", rubocop_path)
|
27
|
+
copy_and_set_executable("general-pre-#{type}", general_path) unless File.exist?(general_path)
|
28
|
+
|
29
|
+
# Ensure we do not append to the general hook file more than once
|
30
|
+
unless File.readlines(general_path).grep(/rubocop-pre-#{type}/).size > 0
|
31
|
+
append_to_file(general_path, "exec #{rubocop_path}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Overrides can go here, but try to conform to TXI standards when possible.
|
2
|
+
#
|
3
|
+
# Example...
|
4
|
+
# Metrics/CyclomaticComplexity:
|
5
|
+
# Enabled: false # We've got nasty methods!
|
6
|
+
#
|
7
|
+
#
|
8
|
+
# Example...
|
9
|
+
# AllCops:
|
10
|
+
# TargetRubyVersion: 2.3
|
11
|
+
# TargetRailsVersion: 4.2
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# This file is generated as a part of the tablexi_dev-generators project
|
2
|
+
#
|
3
|
+
# You should NOT make any changes to this file, as it will be overwritten
|
4
|
+
# the next time we update the tablexi_dev-generators gem and run
|
5
|
+
# `rails generate tablexi_dev:rubocop`
|
6
|
+
AllCops:
|
7
|
+
DisplayCopNames: true
|
8
|
+
Exclude:
|
9
|
+
- "db/schema.rb" # You can't touch this
|
10
|
+
- ".bundle/**/*" # Auto-generated
|
11
|
+
- "bin/**/*" # Auto-generated
|
12
|
+
- "vendor/**/*" # We cannot solve the world's problems
|
13
|
+
TargetRubyVersion: 2.4
|
14
|
+
TargetRailsVersion: 5.1
|
15
|
+
Rails:
|
16
|
+
Enabled: true
|
17
|
+
|
18
|
+
Lint/HandleExceptions:
|
19
|
+
Exclude:
|
20
|
+
- "config/unicorn/*"
|
21
|
+
|
22
|
+
Metrics/AbcSize:
|
23
|
+
Max: 25
|
24
|
+
Exclude:
|
25
|
+
- "db/**/*" # Sometimes migrations are complex.
|
26
|
+
|
27
|
+
Metrics/LineLength:
|
28
|
+
Max: 120
|
29
|
+
|
30
|
+
Metrics/MethodLength:
|
31
|
+
Max: 20
|
32
|
+
Exclude:
|
33
|
+
- "db/**/*" # Again, sometimes DB migrations are long.
|
34
|
+
|
35
|
+
Metrics/BlockLength:
|
36
|
+
Exclude:
|
37
|
+
# These are naturally DSL-y, and so let's be lenient.
|
38
|
+
- "spec/**/*"
|
39
|
+
- "config/routes.rb"
|
40
|
+
|
41
|
+
Style/ClassAndModuleChildren:
|
42
|
+
Exclude:
|
43
|
+
- "app/controllers/**/*" # We generally use compact style here
|
44
|
+
|
45
|
+
Style/Documentation:
|
46
|
+
Exclude:
|
47
|
+
- "db/**/*" # No need to require migrations to be documented.
|
48
|
+
|
49
|
+
Layout/EmptyLinesAroundBlockBody:
|
50
|
+
Exclude:
|
51
|
+
# These are naturally DSL-y, and so let's be lenient.
|
52
|
+
- "spec/**/*"
|
53
|
+
- "lib/tasks/*.rake"
|
54
|
+
|
55
|
+
Layout/EmptyLinesAroundClassBody:
|
56
|
+
EnforcedStyle: empty_lines
|
57
|
+
Exclude:
|
58
|
+
- "db/**/*" # Migrations are compact by default, and it's not worth the wrestle.
|
59
|
+
|
60
|
+
Layout/EmptyLinesAroundModuleBody:
|
61
|
+
EnforcedStyle: empty_lines
|
62
|
+
|
63
|
+
Layout/ExtraSpacing:
|
64
|
+
Exclude:
|
65
|
+
- "db/migrate/*" # Generated migrations often have extra spacing
|
66
|
+
|
67
|
+
Style/SignalException:
|
68
|
+
EnforcedStyle: only_raise
|
69
|
+
|
70
|
+
Layout/SpaceBeforeFirstArg:
|
71
|
+
Exclude:
|
72
|
+
# We often add extra spaces for alignment in factories.
|
73
|
+
- "spec/factories/**/*"
|
74
|
+
- "db/migrate/*" # We often add extra spaces for alignment in migrations.
|
75
|
+
|
76
|
+
Style/StringLiterals:
|
77
|
+
EnforcedStyle: double_quotes
|
78
|
+
|
79
|
+
Style/TrailingCommaInArguments:
|
80
|
+
EnforcedStyleForMultiline: comma
|
81
|
+
|
82
|
+
Style/TrailingCommaInArrayLiteral:
|
83
|
+
EnforcedStyleForMultiline: comma
|
84
|
+
|
85
|
+
Style/TrailingCommaInHashLiteral:
|
86
|
+
EnforcedStyleForMultiline: comma
|
87
|
+
|
88
|
+
Style/TrivialAccessors:
|
89
|
+
ExactNameMatch: true
|
90
|
+
|
91
|
+
Rails/UnknownEnv:
|
92
|
+
Environments:
|
93
|
+
- production
|
94
|
+
- development
|
95
|
+
- test
|
96
|
+
- stage
|
97
|
+
|
98
|
+
Rails/ApplicationRecord:
|
99
|
+
Exclude:
|
100
|
+
- "db/**/*" # Migrations should be isolated, models defined there should NOT inherit from ApplicationRecord
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file is generated as a part of the tablexi_dev-generators project
|
2
|
+
#
|
3
|
+
# You should NOT make any changes to this file, as it will be overwritten
|
4
|
+
# the next time we update the tablexi_dev-generators gem and run
|
5
|
+
# `rails generate tablexi_dev:rubocop`
|
6
|
+
inherit_from:
|
7
|
+
- .rubocop-txi.yml
|
8
|
+
- .rubocop-project_overrides.yml
|
9
|
+
- .rubocop_todo.yml
|
10
|
+
|
11
|
+
# Allow the list of files Excluded by .rubocop-txi to be merged
|
12
|
+
# with files excluded by the .rubocop-project_overrides and .rubocop_todo files
|
13
|
+
inherit_mode:
|
14
|
+
merge:
|
15
|
+
- Exclude
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TablexiDev
|
4
|
+
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class RubocopGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path("../rubocop_generator/files/", __FILE__)
|
10
|
+
|
11
|
+
def copy_files
|
12
|
+
install_rubocop_config_files
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_gem
|
16
|
+
# Prevent us from adding the same gem directive multiple times
|
17
|
+
# if the Gemfile already has 'rubocop' in a format other
|
18
|
+
# than the exact format we expect.
|
19
|
+
content = File.read("Gemfile")
|
20
|
+
gem "rubocop", group: %i[development test], require: false unless content.include?("rubocop")
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def install_rubocop_config_files
|
26
|
+
copy_file "dot_rubocop.yml", ".rubocop.yml"
|
27
|
+
copy_file "dot_rubocop-txi.yml", ".rubocop-txi.yml"
|
28
|
+
|
29
|
+
# Create a .rubocop_todo file, which may be generated
|
30
|
+
# by the `rubocop --auto-gen-config` command
|
31
|
+
create_file ".rubocop_todo.yml" unless File.exist?(".rubocop_todo.yml")
|
32
|
+
|
33
|
+
# Create a file for where individual project-overrides
|
34
|
+
# should be stored, and not be clobbered by the txi rules
|
35
|
+
unless File.exist?(".rubocop-project_overrides.yml") # rubocop:disable Style/GuardClause
|
36
|
+
copy_file "dot_rubocop-project_overrides.yml", ".rubocop-project_overrides.yml"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def copy_and_set_executable(source_file, target_file)
|
41
|
+
copy_file source_file, target_file
|
42
|
+
chmod target_file, 0o755
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
worker_processes 4
|
2
|
+
listen "/tmp/unicorn-<%= @production_domain %>.socket", backlog: 64
|
3
|
+
preload_app true
|
4
|
+
|
5
|
+
app_path = "/home/<%= @app_name %>/<%= @production_domain %>"
|
6
|
+
working_directory "#{app_path}/current"
|
7
|
+
pid "#{app_path}/shared/tmp/pids/unicorn.pid"
|
8
|
+
|
9
|
+
stderr_path "log/unicorn.stderr.log"
|
10
|
+
stdout_path "log/unicorn.stdout.log"
|
11
|
+
|
12
|
+
# zero downtime
|
13
|
+
before_fork do |server, _|
|
14
|
+
# the following is highly recomended for Rails + "preload_app true"
|
15
|
+
# as there's no need for the master process to hold a connection
|
16
|
+
ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
|
17
|
+
|
18
|
+
# Before forking, kill the master process that belongs to the .oldbin PID.
|
19
|
+
# This enables 0 downtime deploys.
|
20
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
21
|
+
if File.exist?(old_pid) && server.pid != old_pid
|
22
|
+
begin
|
23
|
+
Process.kill("QUIT", File.read(old_pid).to_i)
|
24
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
25
|
+
# someone else did our job for us
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
after_fork do |_, _|
|
31
|
+
ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
|
32
|
+
end
|
33
|
+
|
34
|
+
before_exec do |_|
|
35
|
+
ENV["BUNDLE_GEMFILE"] = "#{app_path}/current/Gemfile"
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
worker_processes 2
|
2
|
+
listen "/tmp/unicorn-<%= @app_name %>.stage.tablexi.com.socket", backlog: 64
|
3
|
+
preload_app true
|
4
|
+
|
5
|
+
app_path = "/home/<%= @app_name %>/<%= @app_name %>.stage.tablexi.com"
|
6
|
+
working_directory "#{app_path}/current"
|
7
|
+
pid "#{app_path}/shared/tmp/pids/unicorn.pid"
|
8
|
+
|
9
|
+
stderr_path "log/unicorn.stderr.log"
|
10
|
+
stdout_path "log/unicorn.stdout.log"
|
11
|
+
|
12
|
+
# zero downtime
|
13
|
+
before_fork do |server, _|
|
14
|
+
# the following is highly recomended for Rails + "preload_app true"
|
15
|
+
# as there's no need for the master process to hold a connection
|
16
|
+
ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
|
17
|
+
|
18
|
+
# Before forking, kill the master process that belongs to the .oldbin PID.
|
19
|
+
# This enables 0 downtime deploys.
|
20
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
21
|
+
if File.exist?(old_pid) && server.pid != old_pid
|
22
|
+
begin
|
23
|
+
Process.kill("QUIT", File.read(old_pid).to_i)
|
24
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
25
|
+
# someone else did our job for us
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
after_fork do |_, _|
|
31
|
+
ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
|
32
|
+
end
|
33
|
+
|
34
|
+
before_exec do |_|
|
35
|
+
ENV["BUNDLE_GEMFILE"] = "#{app_path}/current/Gemfile"
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TablexiDev
|
4
|
+
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class UnicornGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path("../unicorn_generator/templates", __FILE__)
|
10
|
+
|
11
|
+
def set_variables
|
12
|
+
@app_name = Rails.application.class.parent.to_s.underscore
|
13
|
+
user_answer = ask("What is the production domain? (leave blank if you don't know yet)")
|
14
|
+
@production_domain = user_answer.presence || "[production-domain]"
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_files
|
18
|
+
template "stage.rb", "config/unicorn/stage.rb"
|
19
|
+
template "production.rb", "config/unicorn/production.rb"
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_gem
|
23
|
+
gem "unicorn", require: false
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tablexi_dev-generators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Table XI
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- devs@tablexi.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- lib/generators/tablexi_dev/all_generator.rb
|
66
|
+
- lib/generators/tablexi_dev/git_hook_generator.rb
|
67
|
+
- lib/generators/tablexi_dev/git_hook_generator/files/general-pre-commit
|
68
|
+
- lib/generators/tablexi_dev/git_hook_generator/files/general-pre-push
|
69
|
+
- lib/generators/tablexi_dev/git_hook_generator/files/rubocop-pre-commit
|
70
|
+
- lib/generators/tablexi_dev/git_hook_generator/files/rubocop-pre-push
|
71
|
+
- lib/generators/tablexi_dev/rubocop_generator.rb
|
72
|
+
- lib/generators/tablexi_dev/rubocop_generator/files/dot_rubocop-project_overrides.yml
|
73
|
+
- lib/generators/tablexi_dev/rubocop_generator/files/dot_rubocop-txi.yml
|
74
|
+
- lib/generators/tablexi_dev/rubocop_generator/files/dot_rubocop.yml
|
75
|
+
- lib/generators/tablexi_dev/unicorn_generator.rb
|
76
|
+
- lib/generators/tablexi_dev/unicorn_generator/templates/production.rb.tt
|
77
|
+
- lib/generators/tablexi_dev/unicorn_generator/templates/stage.rb.tt
|
78
|
+
- lib/tablexi_dev/generators.rb
|
79
|
+
- lib/tablexi_dev/generators/version.rb
|
80
|
+
- lib/tasks/tablexi_dev/generators_tasks.rake
|
81
|
+
homepage: https://github.com/tablexi/tablexi_dev-generators
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.5.2
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: A recommended set of generators for Table XI projects..
|
105
|
+
test_files: []
|