capun 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/capun/setup.rb +24 -0
- data/lib/capun/version.rb +1 -1
- data/lib/generators/capun/install_generator.rb +1 -0
- data/lib/generators/capun/stage_generator.rb +23 -0
- data/lib/generators/capun/templates/backup.sh.erb +11 -1
- data/lib/generators/capun/templates/deploy.rb.erb +1 -0
- data/lib/generators/capun/templates/start.erb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7550bf4a718eae76383022f37c3418bc34f9a4d5
|
4
|
+
data.tar.gz: 6e2bc4558ce4dc659eb9462c06c2bf3165db4612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 967782850fc2f2ace0e1e8715ca61f419a8357cc9ec92e36d6f2da982625480a14f9a53955764ea6cea0ee48c5060ec97c808302753e75a9a6ce1ff23347686c
|
7
|
+
data.tar.gz: 85d9e244b2ec6e71dd371792e4f364c60f2042beeaf07470700af5f59ae88301ae6f08bbde734915ad92b97ed415625aaca63f27220797f7417c8d93e2d5a3ee
|
data/lib/capun/setup.rb
CHANGED
@@ -38,6 +38,8 @@ set :std_uploads, [
|
|
38
38
|
{what: "config/deploy/drivesink.py", where: '#{shared_path}/drivesink.py', upload: true, overwrite: true},
|
39
39
|
# backup.sh.erb
|
40
40
|
{what: "config/deploy/database.yml.erb", where: '#{shared_path}/config/database.yml', upload: true, overwrite: true},
|
41
|
+
# restart script
|
42
|
+
{what: "config/deploy/start.erb", where: '#{release_path}/bin/start', upload: true, overwrite: true},
|
41
43
|
# jenkins' config.xml
|
42
44
|
{what: "config/deploy/jenkins.config.xml.erb", where: '/var/lib/jenkins/jobs/#{fetch(:application)}/config.xml', upload: -> { !!fetch(:addJenkins) }, overwrite: false},
|
43
45
|
# newrelic.yml
|
@@ -64,6 +66,16 @@ namespace :backup do
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
69
|
+
desc "Start server"
|
70
|
+
task :start do
|
71
|
+
invoke 'deploy:kill_me'
|
72
|
+
invoke 'unicorn:start'
|
73
|
+
invoke 'delayed_job:restart' if fetch(:delayed_job)
|
74
|
+
invoke 'clockwork:restart' if fetch(:clockwork)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
|
67
79
|
namespace :predeploy do
|
68
80
|
namespace :install do
|
69
81
|
desc 'Install RVM & Ruby'
|
@@ -201,6 +213,17 @@ namespace :deploy do
|
|
201
213
|
end
|
202
214
|
end
|
203
215
|
|
216
|
+
desc 'Setting up autorestart'
|
217
|
+
task :autorestart do
|
218
|
+
if fetch(:autorestart)
|
219
|
+
on roles(:app) do
|
220
|
+
execute :chmod, "+x #{release_path}/bin/start"
|
221
|
+
info "making start executable"
|
222
|
+
execute :sudo, :ln, "-nfs", "#{release_path}/bin/start /etc/init.d/autorestart-#{fetch(:application).gsub(/\./, '-')}"
|
223
|
+
info "Create symbolic link for autorestart"
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
204
227
|
end
|
205
228
|
|
206
229
|
before "deploy:updating", "deploy:make_dirs"
|
@@ -209,6 +232,7 @@ after "deploy:symlink:linked_dirs", "deploy:upload"
|
|
209
232
|
after "deploy:symlink:linked_dirs", "deploy:add_symlinks"
|
210
233
|
after "deploy:publishing", "deploy:set_up_jenkins"
|
211
234
|
after "deploy:publishing", "deploy:prepare_logrotate"
|
235
|
+
after "deploy:publishing", "deploy:autorestart"
|
212
236
|
after "deploy:publishing", "deploy:restart_nginx"
|
213
237
|
after "deploy:publishing", "deploy:restart_logstash"
|
214
238
|
after "deploy:publishing", "deploy:update_cron"
|
data/lib/capun/version.rb
CHANGED
@@ -15,6 +15,7 @@ module Capun
|
|
15
15
|
|
16
16
|
def copy_files
|
17
17
|
empty_directory "config/deploy"
|
18
|
+
copy_file "start.erb", "config/deploy/start.erb"
|
18
19
|
copy_file "database.yml.erb", "config/deploy/database.yml.erb"
|
19
20
|
copy_file "unicorn.config.rb.erb", "config/deploy/unicorn.config.rb.erb"
|
20
21
|
copy_file "nginx.conf.erb", "config/deploy/nginx.conf.erb"
|
@@ -23,6 +23,9 @@ module Capun
|
|
23
23
|
@addELK = ask("Would you like to add ELK-compatible logging? [Y/n]").capitalize == 'Y'
|
24
24
|
@addlogrotate = ask("Would you like to add logrotate configuration to stage? [Y/n]").capitalize == 'Y'
|
25
25
|
@useBackups = ask("Would you like to add amazon backup system? [Y/n]").capitalize == 'Y'
|
26
|
+
@addDelayedJob = ask("Would you like to add delayed job worker? [Y/n]").capitalize == 'Y'
|
27
|
+
@addClockwork = ask("Would you like to add clockwork worker? [Y/n]").capitalize == 'Y'
|
28
|
+
@autorestart = ask("Would you like to start application after server restart? [Y/n]").capitalize == 'Y'
|
26
29
|
end
|
27
30
|
|
28
31
|
def add_stage
|
@@ -100,6 +103,26 @@ module Capun
|
|
100
103
|
end
|
101
104
|
end
|
102
105
|
|
106
|
+
def addDelayedJob
|
107
|
+
if @addDelayedJob
|
108
|
+
append_to_file "config/deploy.rb","set :delayed_job, true\n"
|
109
|
+
append_to_file "Gemfile","gem 'delayed_job'\n"
|
110
|
+
append_to_file "Gemfile","gem 'delayed_job_active_record'\n"
|
111
|
+
append_to_file "Gemfile","gem 'capistrano3-delayed-job', '~> 1.0'\n"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
def addClockwork
|
115
|
+
if @addClockwork
|
116
|
+
append_to_file "config/deploy.rb","set :clockwork, true\n"
|
117
|
+
append_to_file "Gemfile","gem 'clockwork'\n"
|
118
|
+
append_to_file "Gemfile","gem 'capistrano-clockwork'\n"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
def addAutorestart
|
122
|
+
if @autorestart
|
123
|
+
append_to_file "config/deploy/#{singular_name}.rb", "set :autorestart, true\n"
|
124
|
+
end
|
125
|
+
end
|
103
126
|
def add_jenkins
|
104
127
|
if @addJenkins
|
105
128
|
copy_file "jenkins.config.xml.erb", "config/deploy/jenkins.config.xml.erb"
|
@@ -19,7 +19,17 @@ database=$(cat config/database.yml | grep database | sed s/database://g | xargs)
|
|
19
19
|
mysqldump --user="$username" --password="$password" $database > "backuping/version-$curdate/<%=fetch(:stage)%>.sql"
|
20
20
|
fi
|
21
21
|
|
22
|
-
|
22
|
+
COUNTER=5
|
23
|
+
until [ $COUNTER -lt 1 ]; do
|
24
|
+
echo COUNTER $COUNTER
|
25
|
+
let COUNTER-=1
|
26
|
+
python drivesink.py upload "backuping" <%= fetch(:backupDestinationFolder) || "backups/firstdedic-server/" + fetch(:application) %> >> log/backup.log
|
27
|
+
if [ $? -eq 0 ]; then
|
28
|
+
let COUNTER=0
|
29
|
+
else
|
30
|
+
let COUNTER-=1
|
31
|
+
fi
|
32
|
+
done
|
23
33
|
|
24
34
|
if [ $? -eq 0 ]; then
|
25
35
|
SIZE=$(du -sh backuping | awk '{print $1}')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zamylin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/generators/capun/templates/newrelic.yml.erb
|
143
143
|
- lib/generators/capun/templates/nginx.conf.erb
|
144
144
|
- lib/generators/capun/templates/stage.rb.erb
|
145
|
+
- lib/generators/capun/templates/start.erb
|
145
146
|
- lib/generators/capun/templates/unicorn.config.rb.erb
|
146
147
|
homepage: https://github.com/zamylin/capun
|
147
148
|
licenses:
|