silvermind_deployment 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/silvermind_deployment/install/install_generator.rb +5 -0
- data/lib/generators/silvermind_deployment/install/templates/deploy.rb +109 -0
- data/lib/generators/silvermind_deployment/install/templates/deploy/production.rb +18 -0
- data/lib/generators/silvermind_deployment/install/templates/eye/production.rb +62 -0
- data/lib/generators/silvermind_deployment/install/templates/unicorn.rb +48 -1
- data/lib/silvermind_deployment/version.rb +1 -1
- data/silvermind_deployment.gemspec +6 -0
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b142f72901ad27f2aa090d27088946998241ff2b
|
4
|
+
data.tar.gz: e0bfabf0d74b470be0e6450a2ed492041241f88f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca28569d3a1f8bd9fe21785eda4cdfecf4e7912cd05466cfb359366830ce75b079be2d9081427a59852c4e8e067ff43cf7ca8ab0f34332b17c2259a7a183f61
|
7
|
+
data.tar.gz: 09dd0868118eb5e5ee02481fcd0519a8874cfcb515cf1f1460f699ebbef13ba5471c85e307332ae7f4a1c30e1f1767eb521c3f43cdcf92495d77862d25e2765b
|
@@ -7,6 +7,11 @@ module SilvermindDeployment
|
|
7
7
|
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
8
8
|
|
9
9
|
def copy_unicorn
|
10
|
+
template 'deploy.rb', 'config/deploy.rb'
|
11
|
+
template 'deploy/production.rb', 'config/deploy/production.rb'
|
12
|
+
|
13
|
+
template 'eye/production.rb', 'config/eye/production.rb'
|
14
|
+
|
10
15
|
template 'unicorn.rb', 'config/unicorn.rb'
|
11
16
|
end
|
12
17
|
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# config valid only for current version of Capistrano
|
2
|
+
lock '3.4.0'
|
3
|
+
|
4
|
+
set :application, 'TODO: your app name'
|
5
|
+
set :repo_url, 'TODO: your rails app git repo url'
|
6
|
+
|
7
|
+
# Default branch is :master
|
8
|
+
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
9
|
+
|
10
|
+
# Default deploy_to directory is /var/www/my_app_name
|
11
|
+
# set :deploy_to, "/home/app_path"
|
12
|
+
|
13
|
+
# Default value for :scm is :git
|
14
|
+
# set :scm, :git
|
15
|
+
|
16
|
+
# Default value for :format is :pretty
|
17
|
+
# set :format, :pretty
|
18
|
+
|
19
|
+
# Default value for :log_level is :debug
|
20
|
+
# set :log_level, :debug
|
21
|
+
|
22
|
+
# Default value for :pty is false
|
23
|
+
# set :pty, true
|
24
|
+
|
25
|
+
# Default value for :linked_files is []
|
26
|
+
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
|
27
|
+
|
28
|
+
# Default value for linked_dirs is []
|
29
|
+
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
|
30
|
+
|
31
|
+
# Default value for default_env is {}
|
32
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
33
|
+
|
34
|
+
# Default value for keep_releases is 5
|
35
|
+
# set :keep_releases, 5
|
36
|
+
|
37
|
+
|
38
|
+
### EYE
|
39
|
+
set :eye_roles, -> { :app }
|
40
|
+
set :eye_env, -> { {rails_env: fetch(:rails_env)} }
|
41
|
+
set :eye_config_file, -> { "#{current_path}/config/eye/#{fetch :rails_env}.rb" }
|
42
|
+
|
43
|
+
|
44
|
+
### Rollbar Deploy Pings
|
45
|
+
set :rollbar_token, 'TODO: your rollbar server side token for deployment notifications'
|
46
|
+
set :rollbar_env, Proc.new { fetch :stage }
|
47
|
+
set :rollbar_role, Proc.new { :app }
|
48
|
+
|
49
|
+
|
50
|
+
namespace :deploy do
|
51
|
+
|
52
|
+
after :restart, :clear_cache do
|
53
|
+
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
54
|
+
# Here we can do anything such as:
|
55
|
+
# within release_path do
|
56
|
+
# execute :rake, 'cache:clear'
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
namespace :eye do
|
64
|
+
|
65
|
+
task :start do
|
66
|
+
on roles(fetch(:eye_roles)), in: :groups, limit: 3, wait: 10 do
|
67
|
+
within current_path do
|
68
|
+
with fetch(:eye_env) do
|
69
|
+
execute :bundle, "exec eye start #{fetch(:eye_app_name)}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
task :stop do
|
76
|
+
on roles(fetch(:eye_roles)), in: :groups, limit: 3, wait: 10 do
|
77
|
+
within current_path do
|
78
|
+
with fetch(:eye_env) do
|
79
|
+
execute :bundle, "exec eye stop #{fetch(:eye_app_name)}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
task :restart do
|
86
|
+
on roles(fetch(:eye_roles)), in: :groups, limit: 3, wait: 10 do
|
87
|
+
within current_path do
|
88
|
+
with fetch(:eye_env) do
|
89
|
+
execute :bundle, "exec eye restart #{fetch(:eye_app_name)}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "Start eye with the desired configuration file"
|
96
|
+
task :load_config do
|
97
|
+
on roles(fetch(:eye_roles)) do
|
98
|
+
within current_path do
|
99
|
+
with fetch(:eye_env) do
|
100
|
+
execute :bundle, "exec eye quit"
|
101
|
+
execute :bundle, "exec eye load #{fetch(:eye_config_file)}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
before "deploy:finished", "eye:load_config"
|
109
|
+
after "deploy:finished", "eye:restart"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# server-based syntax
|
2
|
+
# ======================
|
3
|
+
# Defines a single server with a list of roles and multiple properties.
|
4
|
+
# You can define all roles on a single server, or split them:
|
5
|
+
|
6
|
+
set :deploy_to, "/home/TODO: app_path"
|
7
|
+
|
8
|
+
server '#TODO YOUR-SERVER-URL', user: 'TODO: USER-NAME', roles: %w{app db web}
|
9
|
+
|
10
|
+
set :rails_env, "production"
|
11
|
+
|
12
|
+
set :eye_app_name, "TODO: YOUR-EYE-APP-NAME"
|
13
|
+
|
14
|
+
### RUBY
|
15
|
+
set :rbenv_ruby, '2.2.2'
|
16
|
+
set :rbenv_type, :user
|
17
|
+
set :rbenv_map_bins, %w{rake gem bundle ruby rails unicorn}
|
18
|
+
set :rbenv_prefix, "RAILS_ENV=#{fetch(:rails_env)} RACK_ENV=#{fetch(:rails_env)} #{fetch(:rbenv_path)}/bin/rbenv exec"
|
@@ -0,0 +1,62 @@
|
|
1
|
+
app_name = "TODO: YOUR-EYE-APP-NAME"
|
2
|
+
|
3
|
+
Eye.config do
|
4
|
+
logger "/home/#{app_name}/shared/log/eye.log"
|
5
|
+
|
6
|
+
#mail :host => "mx.some.host", :port => 25, :domain => "some.host"
|
7
|
+
#contact :errors, :mail, 'error@some.host'
|
8
|
+
#contact :dev, :mail, 'dev@some.host'
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
Eye.application(app_name) do |app|
|
13
|
+
|
14
|
+
working_dir "/home/#{app_name}/current"
|
15
|
+
|
16
|
+
group "services" do
|
17
|
+
|
18
|
+
process :unicorn do
|
19
|
+
pid_file "/home/#{app_name}/shared/tmp/pids/unicorn.pid"
|
20
|
+
stdall "/home/#{app_name}/shared/log/eye-unicorn.log"
|
21
|
+
start_command "bundle exec unicorn -c /home/#{app_name}/current/config/unicorn.rb --daemonize"
|
22
|
+
restart_command "kill -USR2 {PID}" # for rolling restarts
|
23
|
+
|
24
|
+
stop_signals [:TERM, 10.seconds]
|
25
|
+
|
26
|
+
#start_timeout 100.seconds
|
27
|
+
#restart_grace 50.seconds
|
28
|
+
end
|
29
|
+
|
30
|
+
# process :mailer_worker do
|
31
|
+
# working_dir '/home/tailorart/current'
|
32
|
+
# pid_file "/home/tailorart/shared/pids/mailer_worker.pid"
|
33
|
+
# start_command "bundle exec sidekiq -c 2 -q mailer"
|
34
|
+
# daemonize true
|
35
|
+
# stdall "log/eye-mailer_worker.log"
|
36
|
+
# end
|
37
|
+
|
38
|
+
# process :default_worker do
|
39
|
+
# pid_file "/home/#{app_name}/shared/tmp/pids/default_worker.pid"
|
40
|
+
# start_command "bundle exec sidekiq -c 1"
|
41
|
+
# daemonize true
|
42
|
+
# stdall "log/eye-default_worker.log"
|
43
|
+
# end
|
44
|
+
|
45
|
+
# process :import_worker do
|
46
|
+
# pid_file "/home/#{app_name}/shared/tmp/pids/import_worker.pid"
|
47
|
+
# start_command "bundle exec sidekiq -c 1 -q importer"
|
48
|
+
# daemonize true
|
49
|
+
# stdall "log/eye-import_worker.log"
|
50
|
+
# end
|
51
|
+
|
52
|
+
# starts the clockwork which schedule (recurring jobs / cron replacement)
|
53
|
+
# process :clock do
|
54
|
+
# pid_file "/home/#{app_name}/shared/tmp/pids/clock.pid"
|
55
|
+
# start_command "bundle exec clockwork config/clock.rb"
|
56
|
+
# daemonize true
|
57
|
+
# stdall "log/eye-clock.log"
|
58
|
+
# end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -1 +1,48 @@
|
|
1
|
-
#
|
1
|
+
# Setup paths
|
2
|
+
if ENV['RACK_ENV'] == 'development'
|
3
|
+
puts "wrong for production!!!!!!!!"
|
4
|
+
#web_root = File.expand_path('tmp')
|
5
|
+
current_path = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
6
|
+
else
|
7
|
+
web_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
8
|
+
current_path = File.join(web_root, 'current')
|
9
|
+
end
|
10
|
+
|
11
|
+
shared_path = File.join(web_root, 'shared')
|
12
|
+
pid_file = File.join(shared_path, 'tmp/pids', 'unicorn.pid')
|
13
|
+
|
14
|
+
HttpRequest::DEFAULTS["rack.url_scheme"] = "http"
|
15
|
+
HttpRequest::DEFAULTS["HTTPS"] = "off"
|
16
|
+
HttpRequest::DEFAULTS["HTTP_X_FORWARDED_PROTO"] = "http"
|
17
|
+
|
18
|
+
|
19
|
+
# Configuration
|
20
|
+
worker_processes 2
|
21
|
+
timeout 30 # restarts workers that hang for 30 seconds
|
22
|
+
preload_app true # faster worker spawn time and needed for newrelic. http://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data
|
23
|
+
pid pid_file
|
24
|
+
listen File.join(shared_path, 'tmp/sockets', 'unicorn.sock'), :backlog => 1024 # default = 1024
|
25
|
+
working_directory current_path
|
26
|
+
|
27
|
+
stderr_path File.join(shared_path, 'log', 'unicorn.stderr.log')
|
28
|
+
stdout_path File.join(shared_path, 'log', 'unicorn.stdout.log')
|
29
|
+
|
30
|
+
|
31
|
+
before_exec do |server|
|
32
|
+
ENV['BUNDLE_GEMFILE'] = "#{current_path}/Gemfile"
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Zero downtime deployment
|
37
|
+
# Kill old process as the new finished spinning up
|
38
|
+
before_fork do |server, worker|
|
39
|
+
old_pid = "#{pid_file}.oldbin"
|
40
|
+
if File.exists?(old_pid) && server.pid != old_pid
|
41
|
+
begin
|
42
|
+
old_pid_content = File.read(old_pid).to_i
|
43
|
+
Process.kill("QUIT", old_pid_content)
|
44
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
45
|
+
# someone else did our job for us
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -42,6 +42,12 @@ Gem::Specification.new do |spec|
|
|
42
42
|
|
43
43
|
spec.add_runtime_dependency "unicorn", ">= 5.0.0"
|
44
44
|
|
45
|
+
#####################################################
|
46
|
+
# Error Reporting
|
47
|
+
#####################################################
|
48
|
+
|
49
|
+
spec.add_runtime_dependency "rollbar"
|
50
|
+
|
45
51
|
#####################################################
|
46
52
|
# Capistrano Deployment
|
47
53
|
#####################################################
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: silvermind_deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Severin Ulrich
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 5.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rollbar
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: capistrano
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +169,9 @@ files:
|
|
155
169
|
- bin/setup
|
156
170
|
- lib/generators/silvermind_deployment/install/USAGE
|
157
171
|
- lib/generators/silvermind_deployment/install/install_generator.rb
|
172
|
+
- lib/generators/silvermind_deployment/install/templates/deploy.rb
|
173
|
+
- lib/generators/silvermind_deployment/install/templates/deploy/production.rb
|
174
|
+
- lib/generators/silvermind_deployment/install/templates/eye/production.rb
|
158
175
|
- lib/generators/silvermind_deployment/install/templates/unicorn.rb
|
159
176
|
- lib/silvermind_deployment.rb
|
160
177
|
- lib/silvermind_deployment/version.rb
|