locum-best-practices 0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 37dbd568428a0a7db41755ce105508feeddf3e33
4
+ data.tar.gz: ad8eb844d10781ba5f27927f9ca4777e8542f3f4
5
+ SHA512:
6
+ metadata.gz: acfd99e1207a6eb9c9103a504ed100a96503b944c29a7395fdaef20d3318f69f6b89e774e06bc5545e667a4f30fdefad896719e13a587865791af43fa03a3bc1
7
+ data.tar.gz: a48875099928ceb685b041dda9fc79bbc718a98c1d0c480faa56574843db34b24e79ab455b0d39b1a62e5a0088719ee93c930256502ed0c6b4e09f39698f6a89
data/.editorconfig ADDED
@@ -0,0 +1,18 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+ [*]
7
+ # Change these settings to your own preference
8
+ indent_style = space
9
+ indent_size = 2
10
+
11
+ # We recommend you to keep these unchanged
12
+ end_of_line = lf
13
+ charset = utf-8
14
+ trim_trailing_whitespace = true
15
+ insert_final_newline = true
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .*
11
+ !/.editorconfig
12
+ !/.gitignore
13
+ !/.rubocop.yml
14
+ .idea/
15
+ doc/
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ Exclude:
3
+ - bin/**/*
4
+ - db/**/*
5
+ RunRailsCops: true
6
+ Style/Documentation:
7
+ Enabled: false
8
+ Style/DoubleNegation:
9
+ Enabled: false
10
+ Metrics/AbcSize:
11
+ Max: 25
12
+ Metrics/LineLength:
13
+ Max: 120
14
+ Metrics/MethodLength:
15
+ Max: 25
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Locum::Best::Practices
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/locum/best/practices`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'locum-best-practices'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install locum-best-practices
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/locum-best-practices. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'yard'
3
+ YARD::Rake::YardocTask.new
data/bin/console ADDED
@@ -0,0 +1,12 @@
1
+ ßrequire "bundler/setup"
2
+ require "locum_best_practices"
3
+
4
+ # You can add fixtures and/or initialization code here to make experimenting
5
+ # with your gem easier. You can also use a different console, if you like.
6
+
7
+ # (If you use this, don't forget to add pry to your Gemfile!)
8
+ # require "pry"
9
+ # Pry.start
10
+
11
+ require "irb"
12
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require 'capistrano/locum/defaults'
2
+ require 'capistrano/locum/assets'
3
+ require 'capistrano/locum/remote'
4
+ require 'capistrano/locum/sidekiq'
5
+ require 'capistrano/locum/ssh'
@@ -0,0 +1 @@
1
+ load File.expand_path('../../tasks/assets.cap', __FILE__)
@@ -0,0 +1,40 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ lock '3.4.0'
4
+ load "config/deploy.rb"
5
+ load "config/deploy/#{fetch(:stage)}.rb"
6
+
7
+ set :deploy_to, "/home/#{fetch(:user)}/projects/#{fetch(:application)}"
8
+ set :unicorn_config_path, "/etc/unicorn/#{fetch(:application)}.#{fetch(:login)}.rb"
9
+ set :unicorn_pid, "/var/run/unicorn/#{fetch(:user)}/#{fetch(:application)}.#{fetch(:login)}.pid"
10
+ set :sidekiq_pid, "#{fetch(:deploy_to)}/shared/tmp/pids/sidekiq-0.pid"
11
+ set :bundle_without, [:development, :test, :console, :doc]
12
+ set :use_sudo, false
13
+
14
+ ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
15
+
16
+ set :scm, :git
17
+ set :format, :pretty
18
+ set :pty, true
19
+
20
+ set :log_level, :info
21
+ set :keep_releases, 5
22
+ set :env, worker_count: 8
23
+
24
+ set :linked_files, fetch(:linked_files, []) + %w(config/database.yml config/application.yml config/newrelic.yml)
25
+ set :linked_dirs, fetch(:linked_dirs, []) + %w(bin log tmp/cache tmp/pids tmp/sockets vendor/bundle public/system)
26
+
27
+ set :default_environments, 'RAILS_ENV=production'
28
+ set :production_rake, "rvm use #{fetch(:rvm_ruby_version)} do bundle exec rake #{fetch(:default_environments)}"
29
+ set :rake, "rvm use #{fetch(:rvm_ruby_version)} do bundle exec rake"
30
+ set :bundle_cmd, "rvm use #{fetch(:rvm_ruby_version)} do bundle"
31
+
32
+ set :assets_roles, [:web, :app, :db]
33
+
34
+ set :sidekiq_start_cmd, "cd #{fetch(:deploy_to)}/current; #{fetch(:bundle_cmd)} exec sidekiq " \
35
+ '--index 0 -C config/sidekiq.yml --environment production --daemon'
36
+ set :sidekiq_stop_cmd, "kill -QUIT `cat #{fetch(:sidekiq_pid)}`"
37
+
38
+ after 'deploy:publishing', 'unicorn:restart'
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path('../../tasks/remote.cap', __FILE__)
@@ -0,0 +1 @@
1
+ load File.expand_path('../../tasks/sidekiq.cap', __FILE__)
@@ -0,0 +1 @@
1
+ load File.expand_path('../../tasks/ssh.cap', __FILE__)
@@ -0,0 +1,22 @@
1
+ namespace :assets do
2
+ desc 'Assets precompile'
3
+ task :compile do
4
+ on roles(:app, :web, :db) do
5
+ execute "cd #{fetch(:deploy_to)}/current; #{fetch(:production_rake)} assets:precompile"
6
+ end
7
+ end
8
+
9
+ desc 'Assets clear'
10
+ task :clear do
11
+ on roles(:app, :wev, :db) do
12
+ execute "cd #{fetch(:deploy_to)}/current; #{fetch(:production_rake)} assets:clean"
13
+ end
14
+ end
15
+
16
+ desc 'Assets nuke'
17
+ task :nuke do
18
+ on roles(:app, :wev, :db) do
19
+ execute "cd #{fetch(:deploy_to)}/current; #{fetch(:production_rake)} assets:clobber"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ namespace :remote do
2
+ # TODO: move comments to README
3
+ # e.g: 'cap stage logs:tail[logfile]' will tail 'shared_path/log/logfile.log'.
4
+ desc 'Tail logs on remote host'
5
+ task :logs, :file do |_t, args|
6
+ on roles(:app) do |server|
7
+ info "Opening a console on: #{server} ..."
8
+ params = "#{fetch(:user)}@#{server}"
9
+ file = "#{args[:file] || fetch(:rails_env)}"
10
+ params += %( -t "tail -f #{fetch(:deploy_to)}/shared/log/#{file}.log")
11
+ info "Read logs for user: #{fetch(:user)}"
12
+ exec "ssh #{params}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ namespace :sidekiq do
2
+ desc 'Sidekiq start'
3
+ task :start do
4
+ on roles(:app, :web) do
5
+ execute "#{fetch(:sidekiq_start_cmd)}"
6
+ end
7
+ end
8
+
9
+ desc 'Sidekiq Stop'
10
+ task :stop do
11
+ on roles(:app, :web) do
12
+ execute "#{fetch(:sidekiq_stop_cmd)}"
13
+ end
14
+ end
15
+
16
+ desc 'Sidekiq restart'
17
+ task :restart do
18
+ on roles(:app, :web) do
19
+ execute "#{fetch(:sidekiq_stop_cmd)}; sleep 5; #{fetch(:sidekiq_start_cmd)}"
20
+ end
21
+ end
22
+
23
+ after 'unicorn:restart', 'sidekiq:restart'
24
+ end
@@ -0,0 +1,17 @@
1
+ namespace :ssh do
2
+ desc 'SSH connect and move to current folder'
3
+ task :connect do
4
+ on roles(:app) do |server|
5
+ server_index = ARGV[2].to_i
6
+
7
+ return if server != roles(:app)[server_index]
8
+
9
+ info "Opening a console on: #{server} ..."
10
+ params = "#{fetch(:user)}@#{server}"
11
+ params += " -p #{server.port}" if server.port
12
+ params += %( -t "cd projects/#{fetch(:application)}/current && bash -l")
13
+ info "Connection success for user: #{fetch(:user)}"
14
+ exec "ssh #{params}"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Locum
2
+ class DeployGenerator < Rails::Generators::Base
3
+ desc <<-EOF
4
+ Prepares application to deploy and add custom stages. `testing` and `production` stages are created by default.
5
+ EOF
6
+
7
+ argument :stages, type: :array, default: [], banner: 'custom stages'
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def add_deploy_templates
11
+ directory 'deploy', '.'
12
+ end
13
+
14
+ def create_custom_stages
15
+ stages.each do |stage|
16
+ template 'deploy/config/deploy/testing.rb.tt', "config/deploy/#{stage}.rb"
17
+ template 'deploy/config/environments/testing.rb.tt', "config/environments/#{stage}.rb"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ require 'capistrano/setup'
2
+ require 'capistrano/deploy'
3
+ require 'capistrano/rvm'
4
+ require 'capistrano/rails'
5
+ require 'capistrano/bundler'
6
+ require 'capistrano/rails/migrations'
7
+ require 'capistrano/rails/assets'
8
+ require 'capistrano3/unicorn'
9
+ require 'capistrano/locum'
10
+
11
+ Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
@@ -0,0 +1,4 @@
1
+ set :user, 'your_ssh_user'
2
+ set :login, 'your_locum_login'
3
+ set :rvm_ruby_version, 'your_ruby_version'
4
+ set :repo_url, 'git@bitbucket.org:DCStudio/your_application_name'
@@ -0,0 +1,8 @@
1
+ set :application, 'your_application_name'
2
+ set :rails_env, :production
3
+ set :ssh_options, forward_agent: true
4
+
5
+ server 'production-host.domain',
6
+ roles: %w(web app db),
7
+ primary: true,
8
+ user: fetch(:user)
@@ -0,0 +1,10 @@
1
+ set :application, 'your_application_name'
2
+ set :rails_env, :testing
3
+ set :keep_releases, 3
4
+ set :env, worker_count: 4
5
+ set :ssh_options, forward_agent: true
6
+
7
+ server 'testing-host.domain',
8
+ roles: %w(web app db),
9
+ primary: true,
10
+ user: fetch(:user)
@@ -0,0 +1,2 @@
1
+ module LocumBestPractices
2
+ end
@@ -0,0 +1,3 @@
1
+ module LocumBestPractices
2
+ VERSION = '0.2'
3
+ end
@@ -0,0 +1,38 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'locum_best_practices/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'locum-best-practices'
7
+ spec.version = LocumBestPractices::VERSION
8
+ spec.authors = %w(DarkWater)
9
+ spec.email = %w(darkwater666@mail.ru)
10
+
11
+ spec.summary = 'Simple best practices, used for soft deployment to locum hosting'
12
+ spec.description = 'Contains deploy configuration'
13
+ spec.homepage = 'http://darkcreative-studio.ru'
14
+
15
+ if spec.respond_to?(:metadata)
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+ else
18
+ fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
19
+ end
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)/) }
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(/^exe/) { |f| File.basename(f) }
24
+ spec.require_paths = %w(lib)
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.10'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+
29
+ spec.add_development_dependency 'redcarpet', '~> 1.17'
30
+ spec.add_development_dependency 'yard', '~> 0.7.5'
31
+
32
+ spec.add_dependency 'capistrano', '~> 3.4.0'
33
+ spec.add_dependency 'capistrano-rails', '~> 1.1'
34
+ spec.add_dependency 'capistrano-rvm'
35
+ spec.add_dependency 'capistrano3-unicorn'
36
+
37
+ spec.add_development_dependency 'rubocop'
38
+ end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: locum-best-practices
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - DarkWater
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: redcarpet
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.5
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: capistrano
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.4.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: capistrano-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: capistrano-rvm
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: capistrano3-unicorn
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Contains deploy configuration
140
+ email:
141
+ - darkwater666@mail.ru
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".editorconfig"
147
+ - ".gitignore"
148
+ - ".rubocop.yml"
149
+ - CODE_OF_CONDUCT.md
150
+ - Gemfile
151
+ - README.md
152
+ - Rakefile
153
+ - bin/console
154
+ - bin/setup
155
+ - lib/capistrano/locum.rb
156
+ - lib/capistrano/locum/assets.rb
157
+ - lib/capistrano/locum/defaults.rb
158
+ - lib/capistrano/locum/remote.rb
159
+ - lib/capistrano/locum/sidekiq.rb
160
+ - lib/capistrano/locum/ssh.rb
161
+ - lib/capistrano/tasks/assets.cap
162
+ - lib/capistrano/tasks/remote.cap
163
+ - lib/capistrano/tasks/sidekiq.cap
164
+ - lib/capistrano/tasks/ssh.cap
165
+ - lib/generators/locum/deploy_generator.rb
166
+ - lib/generators/locum/templates/deploy/Capfile.tt
167
+ - lib/generators/locum/templates/deploy/config/deploy.rb.tt
168
+ - lib/generators/locum/templates/deploy/config/deploy/production.rb.tt
169
+ - lib/generators/locum/templates/deploy/config/deploy/testing.rb.tt
170
+ - lib/locum-best-pratices.rb
171
+ - lib/locum_best_practices/version.rb
172
+ - locum-best-practices.gemspec
173
+ homepage: http://darkcreative-studio.ru
174
+ licenses: []
175
+ metadata:
176
+ allowed_push_host: https://rubygems.org
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubyforge_project:
193
+ rubygems_version: 2.4.8
194
+ signing_key:
195
+ specification_version: 4
196
+ summary: Simple best practices, used for soft deployment to locum hosting
197
+ test_files: []
198
+ has_rdoc: