appboost 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd3c345002cb488bded92efd5100ad9fc629a23c
4
+ data.tar.gz: 27705d0e3bd54765b2701da4fd82966e2db3d4a7
5
+ SHA512:
6
+ metadata.gz: df03107f677e0058b23cad85883943c73117626cb0d8fc52fbbe7263746080c83ed168c229ab11b6ad8fab2608a5097c42f1f6d7780df3003cc4f7d536706e1c
7
+ data.tar.gz: f4df73b23a48f0910a3273ea0ba064bb056a412be730f97039ee8d4729be102acc70273c8db9cb3892681924722452662c51f9b3b09f9fa618fa9c64471521b6
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in appboost.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Yury Korolev
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # Appboost
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'appboost'
10
+
11
+ ## Usage
12
+
13
+
14
+ rails g appboost:install myappdomain.com -a ca -e dev
15
+ rails g appboost:chef_solo yourEC2public.amazonaws.com -d mysql
16
+
17
+ note: fresh ubuntu instancies here: http://cloud-images.ubuntu.com/locator/ec2/
18
+ cd chef
19
+ librarian-chef inst
20
+ knife solo init .
21
+ knife solo bootstrap ubuntu@yourEC2public.compute-1.amazonaws.com
22
+
23
+ cd ..
24
+ blazing init
25
+
26
+ add target
27
+
28
+ target :dev, 'app@yourEC2public.compute-1.amazonaws.com:/home/app/app_name-dev',
29
+ :rails_env => 'dev'
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'appboost/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "appboost"
8
+ spec.version = Appboost::VERSION
9
+ spec.authors = ["Yury Korolev"]
10
+ spec.email = ["yurykorolev@me.com"]
11
+ spec.description = %q{Simple set up blazing unicorn nginx tools}
12
+ spec.summary = %q{Little help for fast deployments}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "activesupport", "> 3.0.0"
22
+ spec.add_dependency "foreman"
23
+ spec.add_dependency "blazing"
24
+ spec.add_dependency "awesome_print"
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,5 @@
1
+ require "appboost/version"
2
+
3
+ module Appboost
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'blazing/recipe'
2
+
3
+ class Blazing::Recipe::DbMigrate < Blazing::Recipe
4
+
5
+ def run(target_options = {})
6
+ super target_options
7
+
8
+ info 'precompiling assets'
9
+ system 'bundle exec rake db:migrate'
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'blazing/recipe'
2
+
3
+ class Blazing::Recipe::DbMigrateAndPrecompileAssets < Blazing::Recipe
4
+
5
+ def run(target_options = {})
6
+ super target_options
7
+
8
+ info 'precompiling assets'
9
+ system 'bundle exec rake RAILS_GROUPS=assets db:migrate assets:precompile'
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'blazing/recipe'
2
+
3
+ class Blazing::Recipe::PrecompileAssets < Blazing::Recipe
4
+
5
+ def run(target_options = {})
6
+ super target_options
7
+
8
+ info 'precompiling assets'
9
+ system 'bundle exec rake RAILS_GROUPS=assets assets:precompile'
10
+ end
11
+
12
+ end
@@ -0,0 +1,30 @@
1
+ require 'blazing/recipe'
2
+
3
+ class Blazing::Recipe::UnicornRestart < Blazing::Recipe
4
+
5
+ def run(target_options = {})
6
+ super target_options
7
+
8
+ info "restarting unicorn"
9
+ system "#{sudo} kill -USR2 #{unicorn_pid}"
10
+ end
11
+
12
+ private
13
+
14
+ def unicorn_pid
15
+ File.read('tmp/pids/unicorn.pid').to_i
16
+ end
17
+
18
+ def application
19
+ options[:app] || pwd
20
+ end
21
+
22
+ def pwd
23
+ Dir.pwd.split('/').last
24
+ end
25
+
26
+ def sudo
27
+ options[:sudo] || 'sudo'
28
+ end
29
+
30
+ end
@@ -0,0 +1,33 @@
1
+ require 'blazing/recipe'
2
+
3
+ class Blazing::Recipe::UpstartRestart < Blazing::Recipe
4
+
5
+ def run(target_options = {})
6
+ super target_options
7
+
8
+ if options[:processes].nil? || options[:processes].empty?
9
+ info "restarting appl"
10
+ system "#{sudo} start #{application} || #{sudo} restart #{application}"
11
+ else
12
+ info "restarting app processes - [#{options[:processes]}"
13
+ options[:processes].each do |p|
14
+ system "#{sudo} start #{application}-#{p} || #{sudo} restart #{application}-#{p}"
15
+ end
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def application
22
+ options[:app] || pwd
23
+ end
24
+
25
+ def pwd
26
+ Dir.pwd.split('/').last
27
+ end
28
+
29
+ def sudo
30
+ options[:sudo] || 'sudo'
31
+ end
32
+
33
+ end
@@ -0,0 +1,3 @@
1
+ module Appboost
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,211 @@
1
+ require 'rails/generators'
2
+ require 'awesome_print'
3
+
4
+ module Appboost
5
+ class ChefSoloGenerator < Rails::Generators::Base
6
+ desc "Generates chef"
7
+
8
+ source_root File.join(File.dirname(__FILE__), '../../../templates')
9
+
10
+ argument :host, type: :string, desc: 'Example: google.com'
11
+
12
+ class_option :database,
13
+ type: :string,
14
+ default: 'postgresql',
15
+ desc: 'mysql or postgresql',
16
+ aliases: '-d'
17
+
18
+ class_option :ssh_pub_key,
19
+ type: :string,
20
+ default: "#{ENV['HOME']}/.ssh/id_rsa.pub"
21
+
22
+ class_option :app_user,
23
+ type: :string,
24
+ default: 'app'
25
+
26
+ class_option :vagrant_box,
27
+ type: :string,
28
+ default: "opscode_ubuntu-12.04-i386_chef-11.4.4"
29
+
30
+ class_option :vagrant_box_url,
31
+ type: :string,
32
+ default: "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04-i386_chef-11.4.4.box"
33
+
34
+ class_option :db_password,
35
+ type: :string,
36
+ default: 'password'
37
+
38
+ class_option :ruby,
39
+ type: :string,
40
+ default: '2.0.0-p0'
41
+
42
+ def copy_files
43
+ template "Cheffile.erb", "chef/Cheffile"
44
+ template "Vagrantfile.erb", "chef/Vagrantfile"
45
+ template "node.json.erb", "chef/nodes/#{host}.json"
46
+ template "user.json.erb", "chef/data_bags/users/#{options[:app_user]}.json"
47
+
48
+ copy_file "chef.gitignore", "chef/.gitignore"
49
+ end
50
+
51
+ private
52
+
53
+ def mysql?
54
+ options[:database] == 'mysql'
55
+ end
56
+
57
+ def postgresql?
58
+ options[:database] == 'postgresql'
59
+ end
60
+
61
+ def postgresql_config
62
+ {
63
+ config: {
64
+ listen_addresses: "*",
65
+ port: "5432"
66
+ },
67
+ pg_hba: [
68
+ {
69
+ type: "local",
70
+ db: "postgres",
71
+ user: "postgres",
72
+ addr: nil,
73
+ method: "trust"
74
+ },
75
+ {
76
+ type: "host",
77
+ db: "all",
78
+ user: "all",
79
+ addr: "0.0.0.0/0",
80
+ method: "md5"
81
+ },
82
+ {
83
+ type: "host",
84
+ db: "all",
85
+ user: "all",
86
+ addr: "::1/0",
87
+ method: "md5"
88
+ }
89
+ ],
90
+ password: {
91
+ postgres: options[:db_password]
92
+ }
93
+ }
94
+ end
95
+
96
+ def mysql_config
97
+ {
98
+ :server_root_password => options[:db_password],
99
+ :server_repl_password => options[:db_password],
100
+ :server_debian_password => options[:db_password],
101
+ :service_name => "mysql",
102
+ :basedir => "/usr",
103
+ :data_dir => "/var/lib/mysql",
104
+ :root_group => "root",
105
+ :mysqladmin_bin => "/usr/bin/mysqladmin",
106
+ :mysql_bin => "/usr/bin/mysql",
107
+ :conf_dir => "/etc/mysql",
108
+ :confd_dir => "/etc/mysql/conf.d",
109
+ :socket => "/var/run/mysqld/mysqld.sock",
110
+ :pid_file => "/var/run/mysqld/mysqld.pid",
111
+ :grants_path => "/etc/mysql/grants.sql"
112
+ }
113
+ end
114
+
115
+ def authorization_config
116
+ {
117
+ sudo: {
118
+ users: [options[:app_user]],
119
+ passwordless: true
120
+ }
121
+ }
122
+ end
123
+
124
+ def common_config
125
+ cfg = {
126
+ nginx: {
127
+ dir: "/etc/nginx",
128
+ log_dir: "/var/log/nginx",
129
+ binary: "/usr/sbin/nginx",
130
+ user: "www-data",
131
+ pid: "/var/run/nginx.pid",
132
+ worker_connections: "1024"
133
+ },
134
+ git: {
135
+ prefix: "/usr/local"
136
+ },
137
+ }
138
+ cfg[:mysql] = mysql_config if mysql?
139
+ cfg[:postgresql] = postgresql_config if postgresql?
140
+ cfg
141
+ end
142
+
143
+ def config
144
+ common_config.merge({
145
+ authorization: authorization_config,
146
+ rbenv: rbenv_config(options[:app_user])
147
+ })
148
+ end
149
+
150
+ def config_json
151
+ config.merge({
152
+ run_list: run_list
153
+ })
154
+ end
155
+
156
+ def vagrant_config
157
+ # common_config.merge({
158
+ # rbenv: rbenv_config('vagrant')
159
+ # })
160
+ config
161
+ end
162
+
163
+ def run_list
164
+ [
165
+ "apt",
166
+ "chef-solo-search",
167
+ "locale",
168
+ "users::sysadmins",
169
+ "sudo",
170
+ "runit",
171
+ mysql? ? "mysql::server" : nil,
172
+ postgresql? ? "postgresql::server" : nil,
173
+ "imagemagick",
174
+ "ruby_build",
175
+ "rbenv::user",
176
+ "nginx::repo",
177
+ "nginx",
178
+ "git"
179
+ ].compact
180
+ end
181
+
182
+ def app_name
183
+ Dir.pwd.split('/').last
184
+ end
185
+
186
+ def user_json
187
+ {
188
+ id: options[:app_user],
189
+ comment: "Application User",
190
+ ssh_keys: [File.read(options[:ssh_pub_key])],
191
+ groups: ["sysadmin", "sudo", "staff"],
192
+ shell: "/bin/bash"
193
+ }
194
+ end
195
+
196
+
197
+ def rbenv_config(user)
198
+ {
199
+ user_installs: [{
200
+ user: user,
201
+ rubies: [ options[:ruby] ],
202
+ global: options[:ruby],
203
+ environment: { CFLAGS: "-march=native -O2 -pipe" },
204
+ gems: {
205
+ options[:ruby] => [{name: "bundler", version: "1.3.5"}]
206
+ }
207
+ }]
208
+ }
209
+ end
210
+ end
211
+ end
@@ -0,0 +1,69 @@
1
+ require 'rails/generators'
2
+ module Appboost
3
+ class ForemanExportGenerator < Rails::Generators::Base
4
+ desc "Foreman export"
5
+
6
+ def self.default_procfile
7
+ e = Rails.env == 'development' ? nil : Rails.env
8
+ ['Procfile', e].compact.join('.')
9
+ end
10
+
11
+ def self.default_log
12
+ Rails.root.join('log/foreman').to_s
13
+ end
14
+
15
+ def self.default_directory
16
+ Rails.root.to_s
17
+ end
18
+
19
+ def self.default_app_name
20
+ Dir.pwd.split('/').last
21
+ end
22
+
23
+ class_option :format,
24
+ type: :string,
25
+ default: 'upstart',
26
+ desc: 'Format of foreman export'
27
+
28
+ class_option :location,
29
+ type: :string,
30
+ default: '/etc/init'
31
+
32
+ class_option :user,
33
+ type: :string,
34
+ default: 'app'
35
+
36
+ class_option :app,
37
+ type: :string,
38
+ default: default_app_name
39
+
40
+ class_option :procfile,
41
+ type: :string,
42
+ default: default_procfile
43
+
44
+ class_option :concurrency,
45
+ type: :string
46
+
47
+ class_option :log,
48
+ type: :string,
49
+ default: default_log
50
+
51
+ class_option :directory,
52
+ type: :string,
53
+ default: default_directory
54
+
55
+ def export
56
+ args = ["#{options[:format]} #{options[:location]}"]
57
+ args << "-f #{options[:procfile]}"
58
+ args << "-a #{options[:app]}"
59
+ args << "-u #{options[:user]}"
60
+ args << "-d #{options[:directory]}"
61
+ args << "-l #{options[:log]}"
62
+ args << "-c #{options[:concurrency]}" if options[:concurrency]
63
+
64
+ system "bundle exec foreman export #{args.join(' ')}"
65
+ end
66
+
67
+
68
+ end
69
+ end
@@ -0,0 +1,32 @@
1
+ require 'rails/generators'
2
+ module Appboost
3
+ class HostSiteGenerator < Rails::Generators::Base
4
+ desc "Copy nginx conf file to nginx enabled sites folder"
5
+
6
+ class_option :nginx_sites,
7
+ type: :string,
8
+ default: '/etc/nginx/sites-enabled',
9
+ desc: 'Nginx sites enabled path',
10
+ aliases: '-n'
11
+
12
+ class_option :reload_nginx,
13
+ type: :boolean,
14
+ default: true,
15
+ desc: 'Reload nginx after copying conf file',
16
+ aliases: '-r'
17
+
18
+ def copy_nginx_config
19
+ copy_file "#{Dir.pwd}/config/nginx/#{app_name}.conf", "#{options[:nginx_sites]}/#{app_name}.conf"
20
+ end
21
+
22
+ def reload_nginx
23
+ system "/etc/init.d/nginx reload" if options[:reload_nginx]
24
+ end
25
+
26
+ private
27
+
28
+ def app_name
29
+ Dir.pwd.split('/').last
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,58 @@
1
+ require 'rails/generators'
2
+ module Appboost
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "Generates unicorn conf and nginx conf"
5
+ source_root File.join(File.dirname(__FILE__), '../../../templates')
6
+
7
+ argument :host_base, type: :string, desc: 'Example: google.com'
8
+
9
+ class_option :app_name,
10
+ type: :string,
11
+ default: Rails.application.class.to_s.split("::").first.downcase,
12
+ aliases: '-a'
13
+
14
+ class_option :host_root,
15
+ type: :string,
16
+ default: '/home/app',
17
+ desc: 'Server root_path base',
18
+ aliases: '-r'
19
+
20
+ class_option :listen,
21
+ type: :numeric,
22
+ default: 80,
23
+ desc: "nginx listen port",
24
+ aliases: '-p'
25
+
26
+ class_option :env,
27
+ type: :string,
28
+ default: Rails.env,
29
+ desc: 'Rails environment',
30
+ aliases: '-e'
31
+
32
+ def server_name
33
+ [rails_env, host_base].compact.join(".")
34
+ end
35
+
36
+ def app_name
37
+ options[:app_name]
38
+ end
39
+
40
+ def app_env_name
41
+ [app_name, rails_env].compact.join("-")
42
+ end
43
+
44
+ def generate_unicorn
45
+ template "unicorn.rb.erb", "config/unicorn.rb"
46
+ end
47
+
48
+ def generate_nginx
49
+ template "nginx_unicorn.conf.erb", "config/nginx/#{app_env_name}.conf"
50
+ end
51
+
52
+ private
53
+
54
+ def rails_env
55
+ options[:env] == "production" ? nil : options[:env]
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,17 @@
1
+ site 'http://community.opscode.com/api/v1'
2
+
3
+ cookbook "apt"
4
+ <% if options[:database] == 'mysql' %>
5
+ cookbook "mysql", {}
6
+ <% elsif options[:database] == 'postgresql' %>
7
+ cookbook "postgresql", {}
8
+ <% end %>
9
+ cookbook "sudo", {:gihub => "patcon/chef-sudo"}
10
+ cookbook "locale", {:github => "yury/hw-chef-locale"}
11
+ cookbook "imagemagick"
12
+ cookbook "chef-solo-search", {:github => "edelight/chef-solo-search"}
13
+ cookbook "users"
14
+ cookbook "ruby_build", {:github=>"fnichol/chef-ruby_build", :ref=>"v0.7.2"}
15
+ cookbook "rbenv", {:github=>"fnichol/chef-rbenv"}
16
+ cookbook "nginx", {:github=> "opscode-cookbooks/nginx"}
17
+ cookbook "git", {}
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ # -*- mode: ruby -*-
4
+ # vi: set ft=ruby :
5
+
6
+ Vagrant::Config.run do |config|
7
+
8
+ config.vm.box = "<%= options[:vagrant_box] %>"
9
+ config.vm.box_url = "<%= options[:vagrant_box_url] %>"
10
+ # config.ssh.forward_agent = true
11
+
12
+ config.vm.provision :chef_solo do |chef|
13
+ chef.cookbooks_path = ["cookbooks"]
14
+ chef.data_bags_path = "data_bags"
15
+ <% run_list.each do |recipe| -%>
16
+ chef.add_recipe '<%= recipe %>'
17
+ <% end -%>
18
+ chef.json = <%= AwesomePrint::Inspector.new(plain: true, index: false, indent: -2).awesome(vagrant_config).gsub("\n", "\n ") %>
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ .vagrant
2
+ tmp
3
+ cookbooks
@@ -0,0 +1,40 @@
1
+ upstream <%= app_env_name %>-unicorn {
2
+ server unix:/tmp/unicorn.<%= app_name %>.<%= Rails.env %>.sock fail_timeout=0;
3
+ }
4
+
5
+ server {
6
+ listen <% options[:listen] %>;
7
+ server_name www.<%= server_name %>;
8
+ rewrite ^(.*) http://<%= server_name %>$1 permanent;
9
+ }
10
+
11
+ server {
12
+ listen <% options[:listen] %>;
13
+ server_name <%= server_name %>;
14
+
15
+ root <%=options.host_root%>/<%=app_env_name%>/public;
16
+
17
+ location /assets {
18
+ location ~ \.(js|css|otf|ttf|eot|woff|svg)$ {
19
+ gzip_static on; # to serve pre-gzipped version
20
+ }
21
+
22
+ expires max;
23
+ add_header Cache-Control public;
24
+ }
25
+
26
+ try_files $uri/index.html $uri.html $uri @app;
27
+
28
+ location @app {
29
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30
+ proxy_set_header Host $http_host;
31
+ add_header X-UA-Compatible IE=Edge,chrome=1;
32
+ add_header imagetoolbar no;
33
+ proxy_redirect off;
34
+ proxy_pass http://<%= app_env_name %>-unicorn;
35
+ }
36
+
37
+ error_page 500 502 503 504 /500.html;
38
+ client_max_body_size 4G;
39
+ keepalive_timeout 10;
40
+ }
@@ -0,0 +1 @@
1
+ <%= JSON.pretty_generate(config_json) %>
@@ -0,0 +1,70 @@
1
+ # Sample configuration file for Unicorn (not Rack)
2
+ #
3
+ # See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
4
+ # documentation.
5
+ env ||= ENV["RACK_ENV"] || "development"
6
+ root = File.expand_path('../..', __FILE__)
7
+ # Use at least one worker per core if you're on a dedicated server,
8
+ # more will usually help for _short_ waits on databases/caches.
9
+ worker_processes 4
10
+
11
+ # Help ensure your application will always spawn in the symlinked
12
+ # "current" directory that Capistrano sets up.
13
+ working_directory root # available in 0.94.0+
14
+
15
+ # listen on both a Unix domain socket and a TCP port,
16
+ # we use a shorter backlog for quicker failover when busy
17
+ listen "/tmp/unicorn.<%= app_name %>.#{env.downcase}.sock", :backlog => 64
18
+
19
+ # nuke workers after 60 seconds (the default)
20
+ timeout 60
21
+
22
+ # feel free to point this anywhere accessible on the filesystem
23
+ pid "#{root}/tmp/pids/unicorn.pid"
24
+
25
+ # some applications/frameworks log to stderr or stdout, so prevent
26
+ # them from going to /dev/null when daemonized here:
27
+ stderr_path "#{root}/log/unicorn.stderr.log"
28
+ stdout_path "#{root}/log/unicorn.stdout.log"
29
+
30
+ # combine REE with "preload_app true" for memory savings
31
+ # http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
32
+ preload_app true
33
+ GC.respond_to?(:copy_on_write_friendly=) and
34
+ GC.copy_on_write_friendly = true
35
+
36
+ before_fork do |server, worker|
37
+ Kernel.rand
38
+ # the following is highly recomended for Rails + "preload_app true"
39
+ # as there's no need for the master process to hold a connection
40
+ defined?(ActiveRecord::Base) and
41
+ ActiveRecord::Base.connection.disconnect!
42
+
43
+ # The following is only recommended for memory/DB-constrained
44
+ # installations. It is not needed if your system can house
45
+ # twice as many worker_processes as you have configured.
46
+ #
47
+ # # This allows a new master process to incrementally
48
+ # # phase out the old master process with SIGTTOU to avoid a
49
+ # # thundering herd (especially in the "preload_app false" case)
50
+ # # when doing a transparent upgrade. The last worker spawned
51
+ # # will then kill off the old master process with a SIGQUIT.
52
+ old_pid = "#{server.config[:pid]}.oldbin"
53
+ if old_pid != server.pid
54
+ begin
55
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
56
+ Process.kill(sig, File.read(old_pid).to_i)
57
+ rescue Errno::ENOENT, Errno::ESRCH
58
+ end
59
+ end
60
+ #
61
+ # # *optionally* throttle the master from forking too quickly by sleeping
62
+ sleep 1
63
+ end
64
+
65
+ after_fork do |server, worker|
66
+ Kernel.rand
67
+ # the following is *required* for Rails + "preload_app true",
68
+ defined?(ActiveRecord::Base) and
69
+ ActiveRecord::Base.establish_connection
70
+ end
@@ -0,0 +1 @@
1
+ <%= JSON.pretty_generate(user_json) %>
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appboost
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yury Korolev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>'
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>'
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: foreman
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: blazing
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Simple set up blazing unicorn nginx tools
98
+ email:
99
+ - yurykorolev@me.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - appboost.gemspec
110
+ - lib/appboost.rb
111
+ - lib/appboost/blazing/db_migrate.rb
112
+ - lib/appboost/blazing/db_migrate_and_precompile_assets.rb
113
+ - lib/appboost/blazing/precompile_assets.rb
114
+ - lib/appboost/blazing/unicorn_restart.rb
115
+ - lib/appboost/blazing/upstart_restart.rb
116
+ - lib/appboost/version.rb
117
+ - lib/generators/appboost/chef_solo_generator.rb
118
+ - lib/generators/appboost/foreman_export_generator.rb
119
+ - lib/generators/appboost/host_site_generator.rb
120
+ - lib/generators/appboost/install_generator.rb
121
+ - templates/Cheffile.erb
122
+ - templates/Vagrantfile.erb
123
+ - templates/chef.gitignore
124
+ - templates/nginx_unicorn.conf.erb
125
+ - templates/node.json.erb
126
+ - templates/unicorn.rb.erb
127
+ - templates/user.json.erb
128
+ homepage: ''
129
+ licenses:
130
+ - MIT
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.0.3
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Little help for fast deployments
152
+ test_files: []