visionbundles 0.3.1 → 0.3.2
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/CHANGELOG +6 -0
- data/lib/tasks/assets.rake +5 -6
- data/lib/visionbundles/recipes/fast_assets.rb +2 -3
- data/lib/visionbundles/recipes/puma.rb +20 -2
- data/lib/visionbundles/recipes/secret.rb +14 -11
- data/lib/visionbundles/templates/nginx/nginx.conf.erb +1 -1
- data/lib/visionbundles/templates/puma/config.erb +11 -7
- data/lib/visionbundles/templates/puma/service.erb +19 -0
- data/lib/visionbundles/version.rb +1 -1
- 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: 2ae47de699ad134f9191cbfd5de8c035644219bc
|
4
|
+
data.tar.gz: 671f5c4e28c64d66678cead85668a414049badec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc836a2cee8511bb7e7eb3981974aa1c4b6adda1f24abcf98761f4f19afcd8f4e905ba89214547138161c1491167f20f9cc8aa54159c79847954664253513cf
|
7
|
+
data.tar.gz: cf886aa2ce40c0fc24833c855bd4e00538b611ceb7065e32025da979f49b63fdae12c6015cfdc11eebcfd068b2321cb28e281a54c01a4b43629034d19e7cc35c
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.3.2
|
2
|
+
|
3
|
+
* Refactor the secret, db tasks in recipes, preconfig instead.
|
4
|
+
* Refactor and recipes file structure.
|
5
|
+
* Add an executable shell script to "/init.d/#{application} start|stop|restart", when server boot will run app.
|
6
|
+
|
1
7
|
0.3.1
|
2
8
|
|
3
9
|
* Resolve wrong assets host when compile assets locally. dynamic get `Application.assets.version` from remote and set the same value in local for compile assets [sprockets-rails](https://github.com/rails/sprockets-rails/blob/53f640ed38a509253e869305eb4de7ce3d5cb776/lib/sprockets/railtie.rb#L74)
|
data/lib/tasks/assets.rake
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
namespace :assets do
|
2
|
-
task :
|
3
|
-
puts Rails.application.
|
2
|
+
task :remote_assets_host => :environment do
|
3
|
+
puts Rails.application.config.action_controller.asset_host
|
4
4
|
end
|
5
5
|
|
6
|
-
task :precompile_locally
|
7
|
-
|
8
|
-
|
9
|
-
}
|
6
|
+
task :precompile_locally do
|
7
|
+
ENV['asset_host'] = ENV['remote_assets_host']
|
8
|
+
Rake::Task['environment'].invoke
|
10
9
|
Rake::Task['assets:precompile'].invoke
|
11
10
|
end
|
12
11
|
end
|
@@ -26,9 +26,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
26
26
|
desc "Precompile assets locally"
|
27
27
|
task :precompile, only: { primary: true }, on_no_matching_servers: :continue do
|
28
28
|
server = find_servers(roles: :app, except: { no_release: true }).first
|
29
|
-
|
30
|
-
|
31
|
-
run_locally "#{precompile_cmd} remote_assets_version=#{remote_assets_version}"
|
29
|
+
remote_assets_host = capture("cd #{release_path}; RAILS_ENV=#{precompile_env.to_s.shellescape} bundle exec rake assets:remote_assets_host", hosts: server.to_s).strip
|
30
|
+
run_locally "#{precompile_cmd} remote_assets_host=#{remote_assets_host}"
|
32
31
|
end
|
33
32
|
|
34
33
|
desc "Sync manifest on app servers"
|
@@ -6,23 +6,41 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
6
6
|
set_default(:puma_thread_max, 16)
|
7
7
|
set_default(:puma_workers, 0)
|
8
8
|
set_default(:puma_config_template) { "../templates/puma/config.erb" }
|
9
|
+
set_default(:service_template) { "../templates/puma/service.erb" }
|
9
10
|
set_default(:puma_preload_app) { false }
|
10
11
|
set_default(:puma_prune_bundler) { false }
|
11
12
|
set_default(:puma_worker_timeout) { nil }
|
12
13
|
set_default(:puma_on_boot_connection_to_activerecord) { nil }
|
14
|
+
set_default(:puma_reload_gem_when_restart) { true }
|
13
15
|
|
14
16
|
namespace :puma do
|
15
17
|
desc "Setup Puma Scripts"
|
16
18
|
task :setup, roles: :app do
|
19
|
+
# Copy configuration template to remote server
|
17
20
|
info '[Puma] copying the config'
|
18
21
|
template puma_config_template, "#{shared_path}/puma", "config.rb"
|
22
|
+
|
23
|
+
# Copy service launcher to remote server "init.d/"
|
24
|
+
template service_template, "#{shared_path}/puma", "service"
|
25
|
+
service_remote_path = "#{shared_path}/puma/service"
|
26
|
+
run "chmod +x #{service_remote_path}"
|
27
|
+
sudo "rm -rf /etc/init.d/#{application}"
|
28
|
+
sudo "ln -s #{service_remote_path} /etc/init.d/#{application}"
|
29
|
+
|
30
|
+
# Setup app as a daemon
|
31
|
+
sudo "update-rc.d #{application} defaults"
|
19
32
|
end
|
20
33
|
after 'deploy:setup', 'puma:setup'
|
21
34
|
|
22
|
-
|
35
|
+
desc "start puma"
|
36
|
+
task :start, roles: :app do
|
37
|
+
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec puma -C #{shared_path}/puma/config.rb start"
|
38
|
+
end
|
39
|
+
|
40
|
+
%w[stop restart stats status phased-restart].each do |command|
|
23
41
|
desc "#{command} puma server"
|
24
42
|
task command, roles: :app do
|
25
|
-
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec pumactl -
|
43
|
+
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec pumactl -S #{shared_path}/pids/puma.state #{command}"
|
26
44
|
end
|
27
45
|
end
|
28
46
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
Capistrano::Configuration.instance(:must_exist).load do
|
2
2
|
begin
|
3
3
|
require 'rails'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
rescue e
|
5
|
+
raise 'require rails faild'
|
6
|
+
end
|
7
|
+
|
8
|
+
major, minor = Rails::VERSION::STRING.split('.').map(&:to_i)
|
9
|
+
if major == 4 && [0, 1].include?(minor)
|
10
|
+
source, desc = case minor
|
11
|
+
when 0 then; ['secret_token.rb', 'config/initializers/secret_token.rb']
|
12
|
+
when 1 then; ['secrets.yml', 'config/secrets.yml']
|
13
13
|
end
|
14
|
-
|
15
|
-
|
14
|
+
preconfig_files(source => desc)
|
15
|
+
else
|
16
|
+
raise 'Only support rails 4.1.x and 4.0.x'
|
17
|
+
end
|
18
|
+
end
|
@@ -20,13 +20,13 @@ directory '<%= app_root %>'
|
|
20
20
|
#
|
21
21
|
# The default is “config.ru”.
|
22
22
|
#
|
23
|
-
|
23
|
+
rackup '<%= "#{app_root}/config.ru" %>'
|
24
24
|
|
25
25
|
# Set the environment in which the rack's app will run. The value must be a string.
|
26
26
|
#
|
27
27
|
# The default is “development”.
|
28
28
|
#
|
29
|
-
|
29
|
+
environment '<%= rails_env %>'
|
30
30
|
|
31
31
|
# Daemonize the server into the background. Highly suggest that
|
32
32
|
# this be combined with “pidfile” and “stdout_redirect”.
|
@@ -38,12 +38,12 @@ daemonize
|
|
38
38
|
|
39
39
|
# Store the pid of the server in the file at “path”.
|
40
40
|
#
|
41
|
-
pidfile "<%=
|
41
|
+
pidfile "<%= shared_path %>/pids/puma.pid"
|
42
42
|
|
43
43
|
# Use “path” as the file to store the server info state. This is
|
44
44
|
# used by “pumactl” to query and control the server.
|
45
45
|
#
|
46
|
-
|
46
|
+
state_path "<%= shared_path %>/pids/puma.state"
|
47
47
|
|
48
48
|
# Redirect STDOUT and STDERR to files specified. The 3rd parameter
|
49
49
|
# (“append”) specifies whether the output is appended, the default is
|
@@ -98,9 +98,13 @@ threads <%= puma_thread_min %>, <%= puma_thread_max %>
|
|
98
98
|
#
|
99
99
|
# This can be called multiple times to add code each time.
|
100
100
|
#
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
|
102
|
+
<% if puma_reload_gem_when_restart %>
|
103
|
+
on_restart do
|
104
|
+
puts 'Refreshing Gemfile'
|
105
|
+
ENV["BUNDLE_GEMFILE"] = "<%= "#{current_path}/Gemfile" %>"
|
106
|
+
end
|
107
|
+
<% end %>
|
104
108
|
|
105
109
|
# Command to use to restart puma. This should be just how to
|
106
110
|
# load puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
|
3
|
+
case "$1" in
|
4
|
+
<% %w(stop restart).each do |command| %>
|
5
|
+
<%= command %>)
|
6
|
+
su -l -c "cd <%= current_path %> && RAILS_ENV=<%= rails_env %> bundle exec pumactl -S <%= shared_path %>/pids/puma.state <%= command %>" <%= user %>
|
7
|
+
;;
|
8
|
+
<% end %>
|
9
|
+
start)
|
10
|
+
echo "Starting <%= application%> application"
|
11
|
+
su -l -c "cd <%= current_path %> && RAILS_ENV=<%= rails_env %> bundle exec puma -C <%= shared_path %>/puma/config.rb start" <%= user %>
|
12
|
+
;;
|
13
|
+
*)
|
14
|
+
echo "Usage: /etc/init.d/<%= application %> {start|stop|restart}"
|
15
|
+
exit 1
|
16
|
+
;;
|
17
|
+
esac
|
18
|
+
|
19
|
+
exit 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionbundles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eddie Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asset_sync
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/visionbundles/recipes/valid.rb
|
109
109
|
- lib/visionbundles/templates/nginx/nginx.conf.erb
|
110
110
|
- lib/visionbundles/templates/puma/config.erb
|
111
|
+
- lib/visionbundles/templates/puma/service.erb
|
111
112
|
- lib/visionbundles/version.rb
|
112
113
|
- todo.md
|
113
114
|
- visionbundles.gemspec
|