biola_deploy 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/biola_deploy/version.rb +1 -1
- data/lib/tasks/deploy.rake +11 -188
- metadata +11 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 37876e7ccc26ce81b6860ff0084e35bc8dd8af0d
|
4
|
+
data.tar.gz: 80d9e9ee2f0806b33ff16db4e16b1149c607471e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4682ae61f9e974da52a8a58d92299b4dff53fd4b3a841b7fcda0a33c5ba3a4df76b2b737db953931039336e97385ece040ef235d28efeae8ce07a7d7989e9ffc
|
7
|
+
data.tar.gz: 4f975e99cc2cae4aca2aa325bee582d201611c84fc73e9d872cba9e86d1dec1c9a95b990e707bbf6c73dc24efb644beb3e850715b87f17163f545365e2ac9f57
|
data/lib/biola_deploy/version.rb
CHANGED
data/lib/tasks/deploy.rake
CHANGED
@@ -1,120 +1,13 @@
|
|
1
|
-
require 'whiskey_disk/helpers'
|
2
1
|
require 'fileutils'
|
3
2
|
require 'uri'
|
4
3
|
|
5
4
|
namespace :deploy do
|
6
|
-
desc 'Create a new user for the app'
|
7
|
-
task :create_user => :environment do
|
8
|
-
unless app_user_exists?
|
9
|
-
puts "creating user #{app_username}..."
|
10
|
-
system "sudo useradd --system --shell /bin/false --home #{app_dir} #{app_username}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
desc 'Put the logs in /var/log and sym link to ./logs'
|
15
|
-
task :prepare_logs => :environment do
|
16
|
-
puts 'preparing logs...'
|
17
|
-
|
18
|
-
# ensure the base log directory for our apps exists
|
19
|
-
system("sudo mkdir #{base_log_dir}") unless Dir.exists?(base_log_dir)
|
20
|
-
|
21
|
-
# create the app's log directory under the base directory and make the app user the owner
|
22
|
-
system "sudo mkdir #{app_log_dir}" unless Dir.exists?(app_log_dir)
|
23
|
-
chown_to_app_user app_log_dir
|
24
|
-
|
25
|
-
# symbolic link the system log directory to the app log directory
|
26
|
-
Dir.chdir(app_dir) do
|
27
|
-
system('rm -rf log') if Dir.exists?('log')
|
28
|
-
FileUtils.ln_s(app_log_dir, 'log')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
desc 'Create the ./tmp directory with the correct permissions'
|
33
|
-
task :prepare_tmp => :environment do
|
34
|
-
puts 'preparing /tmp directory...'
|
35
|
-
Dir.chdir(app_dir) do
|
36
|
-
Dir.mkdir('tmp') unless Dir.exists?('tmp')
|
37
|
-
make_globally_writable 'tmp'
|
38
|
-
chown_to_app_user 'public'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
desc 'Set permissions on ./public'
|
43
|
-
task :prepare_public => :environment do
|
44
|
-
Dir.chdir(app_dir) do
|
45
|
-
make_globally_writable 'public'
|
46
|
-
chown_to_app_user 'public'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
desc 'Configure Nginx to serve the app'
|
51
|
-
task :setup_webserver => :environment do
|
52
|
-
File.open(webserver_app_config_file, 'w') do |file|
|
53
|
-
config = if server?
|
54
|
-
"
|
55
|
-
server {
|
56
|
-
listen 80;
|
57
|
-
listen 443 ssl;
|
58
|
-
server_name #{app_url.host};
|
59
|
-
server_name #{app_url.host.split('.').first}.#{hostname};
|
60
|
-
|
61
|
-
index index.html index.htm;
|
62
|
-
|
63
|
-
location / {
|
64
|
-
root #{app_public_dir};
|
65
|
-
passenger_set_cgi_param HTTP_X_FORWARDED_PROTO $scheme;
|
66
|
-
passenger_enabled on;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
"
|
70
|
-
else
|
71
|
-
"
|
72
|
-
location #{app_url.path} {
|
73
|
-
passenger_enabled on;
|
74
|
-
passenger_base_uri #{app_url.path};
|
75
|
-
passenger_user #{app_username};
|
76
|
-
passenger_group #{app_username};
|
77
|
-
passenger_set_cgi_param HTTP_X_FORWARDED_PROTO $scheme;
|
78
|
-
}
|
79
|
-
"
|
80
|
-
end
|
81
|
-
|
82
|
-
file.write config
|
83
|
-
end
|
84
|
-
|
85
|
-
# sym link the location path
|
86
|
-
if location?
|
87
|
-
FileUtils.ln_s(File.join(app_dir, 'public'), File.join(web_root_dir, app_url.path))
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
desc 'Create the database'
|
92
|
-
task :create_db do
|
93
|
-
host = db_config['host'] || 'localhost'
|
94
|
-
|
95
|
-
if db_config['adapter'] =~ /mysql/
|
96
|
-
client = Mysql2::Client.new(:host => host, :username => ENV['DB_CREATE_USERNAME'], :password => ENV['DB_CREATE_PASSWORD'])
|
97
|
-
db = db_config['database']
|
98
|
-
user = db_config['username']
|
99
|
-
password = db_config['password']
|
100
|
-
|
101
|
-
client.query 'USE mysql'
|
102
|
-
client.query "CREATE DATABASE IF NOT EXISTS #{db}"
|
103
|
-
client.query "GRANT ALL PRIVILEGES ON #{db}.* TO '#{user}'@'%' IDENTIFIED BY '#{password}'"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
5
|
desc 'Run the database migrations'
|
108
6
|
task :migrate_db => :environment do
|
109
7
|
puts 'migrating the database...'
|
110
8
|
Rake::Task['db:migrate'].invoke
|
111
9
|
end
|
112
10
|
|
113
|
-
desc 'TODO'
|
114
|
-
task :setup_solr do
|
115
|
-
# TODO
|
116
|
-
end
|
117
|
-
|
118
11
|
desc 'Reindex Solr if it exists'
|
119
12
|
task :reindex_solr do
|
120
13
|
if Rake::Task.task_defined? 'sunspot:reindex'
|
@@ -131,17 +24,6 @@ location #{app_url.path} {
|
|
131
24
|
end
|
132
25
|
end
|
133
26
|
|
134
|
-
desc 'Trigger a Passenger restart'
|
135
|
-
task :restart_app => :environment do
|
136
|
-
restart_file = 'tmp/restart.txt'
|
137
|
-
|
138
|
-
puts 'restarting the app...'
|
139
|
-
Dir.chdir(app_dir) do
|
140
|
-
make_globally_writable restart_file if File.exists? restart_file
|
141
|
-
FileUtils.touch restart_file
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
27
|
desc 'Tell NewRelic about this deployment'
|
146
28
|
task :tell_newrelic => :environment do
|
147
29
|
require 'new_relic/command'
|
@@ -156,87 +38,28 @@ location #{app_url.path} {
|
|
156
38
|
NewRelic::Command::Deployments.new :revision => version
|
157
39
|
end
|
158
40
|
|
159
|
-
desc '
|
160
|
-
task :
|
41
|
+
desc 'Trigger a Passenger restart'
|
42
|
+
task :restart_app => :environment do
|
43
|
+
restart_file = 'tmp/restart.txt'
|
44
|
+
|
45
|
+
puts 'restarting the app...'
|
46
|
+
Dir.chdir(app_dir) do
|
47
|
+
make_globally_writable restart_file if File.exists? restart_file
|
48
|
+
FileUtils.touch restart_file
|
49
|
+
end
|
50
|
+
end
|
161
51
|
|
162
52
|
desc 'Run all deployment tasks'
|
163
53
|
task :post_deploy => [:migrate_db, :reindex_solr, :precompile_assets, :tell_newrelic, :restart_app]
|
164
54
|
|
165
55
|
private
|
166
|
-
def web_root_dir
|
167
|
-
ENV['WEB_ROOT']
|
168
|
-
end
|
169
56
|
|
170
57
|
def app_dir
|
171
58
|
Rails.root.to_s
|
172
59
|
end
|
173
60
|
|
174
|
-
def app_public_dir
|
175
|
-
File.join(app_dir, 'public')
|
176
|
-
end
|
177
|
-
|
178
|
-
def app_url
|
179
|
-
URI.parse ENV['APP_URL']
|
180
|
-
end
|
181
|
-
alias :app_uri :app_url
|
182
|
-
|
183
|
-
def url_type
|
184
|
-
if app_url.path.to_s.gsub('/', '') == ''
|
185
|
-
:server
|
186
|
-
else
|
187
|
-
:location
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
def server?
|
192
|
-
url_type == :server
|
193
|
-
end
|
194
|
-
|
195
|
-
def location?
|
196
|
-
url_type == :location
|
197
|
-
end
|
198
|
-
|
199
|
-
def app_name
|
200
|
-
ENV['APP_NAME']
|
201
|
-
end
|
202
|
-
|
203
|
-
def app_username
|
204
|
-
app_name
|
205
|
-
end
|
206
|
-
|
207
|
-
def hostname
|
208
|
-
system 'hostname --long'
|
209
|
-
end
|
210
|
-
|
211
|
-
def webserver_app_config_file
|
212
|
-
"/etc/nginx/sites/#{app_name}.#{url_type}.conf"
|
213
|
-
end
|
214
|
-
|
215
|
-
def base_log_dir
|
216
|
-
'/var/log/rails'
|
217
|
-
end
|
218
|
-
|
219
|
-
def app_log_dir
|
220
|
-
File.join(base_log_dir, app_name)
|
221
|
-
end
|
222
|
-
|
223
|
-
def app_user_exists?
|
224
|
-
!!system("id #{app_username}")
|
225
|
-
end
|
226
|
-
|
227
|
-
def chown_to_app_user(file)
|
228
|
-
system "sudo chown -R #{app_username}:#{app_username} #{file}"
|
229
|
-
end
|
230
|
-
|
231
61
|
def make_globally_writable(file)
|
232
62
|
permissions = File.directory?(file) ? 777 : 666
|
233
63
|
system "sudo chmod #{permissions} #{file}"
|
234
64
|
end
|
235
|
-
|
236
|
-
def db_config
|
237
|
-
return @db_config unless @db_config.nil?
|
238
|
-
|
239
|
-
database_yml_path = File.join(changes_file_root, 'config', 'database.yml')
|
240
|
-
@db_config = YAML::load(File.open(database_yml_path))[ENV['RAILS_ENV']]
|
241
|
-
end
|
242
|
-
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,60 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biola_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam Crownoble
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
name: whiskey_disk
|
16
|
-
requirement: &71291250 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.6.24
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: *71291250
|
25
|
-
description: Designed to automate deployment of Biola's applications to it's servers
|
26
|
-
using whiskey_disk friendly rake tasks
|
11
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Designed to automate deployment of Rails applications using rake tasks
|
27
14
|
email: adam.crownoble@biola.edu
|
28
15
|
executables: []
|
29
16
|
extensions: []
|
30
17
|
extra_rdoc_files: []
|
31
18
|
files:
|
32
|
-
- lib/biola_deploy.rb
|
33
19
|
- lib/biola_deploy/version.rb
|
34
20
|
- lib/biola_deploy/engine.rb
|
21
|
+
- lib/biola_deploy.rb
|
35
22
|
- lib/tasks/deploy.rake
|
36
23
|
homepage: https://bitbucket.org/biola/biola-deploy
|
37
24
|
licenses: []
|
25
|
+
metadata: {}
|
38
26
|
post_install_message:
|
39
27
|
rdoc_options: []
|
40
28
|
require_paths:
|
41
29
|
- lib
|
42
30
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
31
|
requirements:
|
45
|
-
- -
|
32
|
+
- - '>='
|
46
33
|
- !ruby/object:Gem::Version
|
47
34
|
version: '0'
|
48
35
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
36
|
requirements:
|
51
|
-
- -
|
37
|
+
- - '>='
|
52
38
|
- !ruby/object:Gem::Version
|
53
39
|
version: '0'
|
54
40
|
requirements: []
|
55
41
|
rubyforge_project:
|
56
|
-
rubygems_version:
|
42
|
+
rubygems_version: 2.0.3
|
57
43
|
signing_key:
|
58
|
-
specification_version:
|
59
|
-
summary: Easy deployment for
|
44
|
+
specification_version: 4
|
45
|
+
summary: Easy deployment for Rails applications
|
60
46
|
test_files: []
|