vpsb 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5011a35083493a07c64a7d9ea82112feae44affb
4
- data.tar.gz: 8eb66e100cb1dda42b2afc8fa889f1834ee5ece4
3
+ metadata.gz: 6bf97c87cc07a64a0b0d5495f4f99d9f96750ffa
4
+ data.tar.gz: e5cce2265df8e1aed3c7726c1a8c209a2fcddabc
5
5
  SHA512:
6
- metadata.gz: 9b8cd025b4dd2725391c5a6a9016f5b41510389f76bdc6a21719099b6f284da49f870c9f179cf54f31d41691f07ac6b3b59164cbb0ffaf9f9ffbcf4d3d9a72ad
7
- data.tar.gz: bf01ddd97ca3386466e19aa07699ad14575104fe86858bc4cbd69076ffb62c4f21081e33fbc85990286a5f84b2af4ecaa7d58a61585dc20b41089b21a3622189
6
+ metadata.gz: 0219ac8c35c73edd2ad964c96f2531a03c02381902d9e8ace34bf0cf0d175a827b761904e706af4f24dcfb5be89c55a336ac792c32dacd1a0b355ae91fb62424
7
+ data.tar.gz: 6960ab47cdb01d902e2b18e1676601efa04e92eb497e9d7615f483cd913cc3d5ffbec06e1fb8285f6a716c312ca0d19225b18806e83efeaf97117eba7ddcd877
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vpsb (1.0.6)
4
+ vpsb (1.0.7)
5
5
  activesupport (~> 4.0)
6
6
  awesome_print (~> 1.2)
7
7
  capistrano (~> 3.1.0)
@@ -0,0 +1,167 @@
1
+ module Vpsb
2
+ module Resources
3
+ class DeployRb < BaseResource
4
+ res :deploy_rb
5
+
6
+ def call(data)
7
+ template(data)
8
+ end
9
+
10
+ private
11
+
12
+ def template(data)
13
+ application = '#{application}'
14
+ deploy_to = '#{deploy_to}'
15
+ command = '#{command}'
16
+ <<-EOF
17
+ # config valid only for Capistrano 3.1
18
+ # set :rsync_options, %w[--recursive --delete --delete-excluded --exclude .git*]
19
+ lock '3.1.0'
20
+ application = 'rails'
21
+ set :user, 'deploy'
22
+
23
+ set :application, application
24
+ set :repo_url, "."
25
+ # set :repository, '.'
26
+ set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master"
27
+ set :deploy_to, "/opt/www/#{application}"
28
+ set :scm, :rsync
29
+
30
+ set :rsync_cache, false
31
+ set :rsync_stage, "tmp/repository"
32
+ # set :rsync_cache, ""
33
+
34
+ # set :deploy_via, :copy
35
+
36
+ set :use_sudo, false
37
+ stage = :production
38
+
39
+ # Default branch is :master
40
+ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
41
+
42
+ # Default value for :scm is :git
43
+ # set :scm, :git
44
+
45
+ # Default value for :format is :pretty
46
+ # set :format, :pretty
47
+
48
+ # Default value for :log_level is :debug
49
+ set :log_level, :debug
50
+
51
+ # Default value for :pty is false
52
+ # set :pty, true
53
+ set :default_shell, "/bin/bash -l"
54
+
55
+ # Default value for :linked_files is []
56
+ # set :linked_files, %w{config/database.yml}
57
+
58
+ # Default value for linked_dirs is []
59
+ set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
60
+
61
+ # Default value for default_env is {}
62
+ # set :default_env, { path: "/opt/ruby/bin:$PATH" }
63
+
64
+ # Default value for keep_releases is 5
65
+ set :keep_releases, 5
66
+
67
+ set :rvm_ruby_version, '2.1.2'
68
+ set :rvm_type, :user
69
+ set :rvm_ruby_string, "2.1.2@#{application}"
70
+
71
+ namespace :unicorn do
72
+ %w{start stop restart reload upgrade}.each do |command|
73
+ desc "#{command} unicorn"
74
+ task command.to_sym do
75
+ on roles(:app), pty: true, shell: true do
76
+ within shared_path do
77
+ execute :sudo, :service, "unicorn_#{application}", command
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ namespace :nginx do
85
+ %w{restart reload}.each do |command|
86
+ desc "#{command} nginx"
87
+ task command.to_sym do
88
+ on roles(:app), pty: true, shell: true do
89
+ within shared_path do
90
+ execute :sudo, :service, :nginx, command
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ namespace :db do
98
+ desc "Create database"
99
+ task :create do
100
+ on roles(:db) do
101
+ within release_path do
102
+ execute :rake, "db:create"
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ namespace :es do
109
+ %w{
110
+ create_indexes
111
+ delete_indexes
112
+ recreate_indexes
113
+ insert_dicts_plants_data
114
+ insert_dicts_precinct_data
115
+ insert_dicts_agri_pack_data
116
+ }.each do |command|
117
+ desc "Elasticsearch #{command} task"
118
+ task command.to_sym do
119
+ on roles(:app) do
120
+ within release_path do
121
+ execute :rake, "es:#{command}"
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ namespace :deploy do
129
+ before 'deploy:migrate', 'db:create'
130
+ before 'deploy', 'deploy:rsync'
131
+
132
+ task :rsync do
133
+ on roles(:app), in: :sequence, pty: true, shell: true do
134
+ `rsync -avz -e ssh "./" deploy@#{data.get(:do_host_ip)}:#{deploy_to}/shared/deploy`
135
+ end
136
+ end
137
+
138
+ desc "First deploy setup unicorn and nginx"
139
+ task :init_env do
140
+ on roles(:app), in: :sequence, wait: 5, pty: true, shell: true do
141
+ Rake::Task['unicorn:start'].invoke
142
+ Rake::Task['nginx:restart'].invoke
143
+ end
144
+ end
145
+
146
+ before :production, :warn do
147
+ info 'Deploying to production, hold tight!'
148
+ stage = :production
149
+ end
150
+
151
+ after :finishing, 'deploy:cleanup'
152
+
153
+ desc 'Restart application'
154
+ task :restart do
155
+ on roles(:app), in: :sequence, wait: 5 do
156
+ Rake::Task['unicorn:upgrade'].invoke
157
+ # Rake::Task['nginx:restart'].invoke
158
+ end
159
+ end
160
+
161
+ after :publishing, :restart
162
+ end
163
+ EOF
164
+ end
165
+ end
166
+ end
167
+ end
@@ -4,13 +4,15 @@ module Vpsb
4
4
  include AskSupport
5
5
 
6
6
  PATH = 'bootstrap_rails_app_in_do/config/deploy/production.rb'
7
+ DEPLOY_RB_PATH = 'bootstrap_rails_app_in_do/config/deploy.rb'
7
8
 
8
- prepare_squence :deploy_config
9
+ prepare_squence :deploy_config, :deploy_rb
9
10
 
10
11
  def call
11
12
  prepare
12
13
 
13
14
  Vpsb::Helpers::FileReplace.replace_text(PATH, core.get(:deploy_config))
15
+ Vpsb::Helpers::FileReplace.replace_text(DEPLOY_RB_PATH, core.get(:deploy_rb))
14
16
  end
15
17
  end
16
18
  end
@@ -1,3 +1,3 @@
1
1
  module Vpsb
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpsb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pawel Niemczyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-11 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -251,6 +251,7 @@ files:
251
251
  - lib/vpsb/resources/deploy_config.rb
252
252
  - lib/vpsb/resources/deploy_keychain.rb
253
253
  - lib/vpsb/resources/deploy_pass.rb
254
+ - lib/vpsb/resources/deploy_rb.rb
254
255
  - lib/vpsb/resources/deploy_ssh_keys.rb
255
256
  - lib/vpsb/resources/deploy_to_known_hosts.rb
256
257
  - lib/vpsb/resources/do_api_key.rb