georgia_recipes 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +1 -0
- data/georgia_recipes.gemspec +24 -0
- data/lib/georgia_recipes/all.rb +24 -0
- data/lib/georgia_recipes/apache.rb +10 -0
- data/lib/georgia_recipes/assets.rb +36 -0
- data/lib/georgia_recipes/base.rb +54 -0
- data/lib/georgia_recipes/carrierwave.rb +39 -0
- data/lib/georgia_recipes/chef.rb +10 -0
- data/lib/georgia_recipes/elasticsearch.rb +21 -0
- data/lib/georgia_recipes/errbit.rb +25 -0
- data/lib/georgia_recipes/georgia.rb +53 -0
- data/lib/georgia_recipes/helper_methods.rb +90 -0
- data/lib/georgia_recipes/imagemagick.rb +10 -0
- data/lib/georgia_recipes/memcached.rb +27 -0
- data/lib/georgia_recipes/mongodb.rb +15 -0
- data/lib/georgia_recipes/monit.rb +56 -0
- data/lib/georgia_recipes/mysql.rb +62 -0
- data/lib/georgia_recipes/newrelic.rb +39 -0
- data/lib/georgia_recipes/nginx.rb +28 -0
- data/lib/georgia_recipes/nodejs.rb +12 -0
- data/lib/georgia_recipes/postgresql.rb +92 -0
- data/lib/georgia_recipes/rbenv.rb +40 -0
- data/lib/georgia_recipes/redis.rb +18 -0
- data/lib/georgia_recipes/sidekiq.rb +22 -0
- data/lib/georgia_recipes/solr.rb +77 -0
- data/lib/georgia_recipes/templates/chef-solo.rb.erb +4 -0
- data/lib/georgia_recipes/templates/memcached.erb +16 -0
- data/lib/georgia_recipes/templates/monit/mysql.erb +6 -0
- data/lib/georgia_recipes/templates/monit/nginx.erb +5 -0
- data/lib/georgia_recipes/templates/monit/postgresql.erb +5 -0
- data/lib/georgia_recipes/templates/monit/sidekiq.erb +4 -0
- data/lib/georgia_recipes/templates/monit/solr.erb +4 -0
- data/lib/georgia_recipes/templates/monit/unicorn.erb +15 -0
- data/lib/georgia_recipes/templates/monit.node.json.erb +14 -0
- data/lib/georgia_recipes/templates/nginx.erb +40 -0
- data/lib/georgia_recipes/templates/postgresql.yml.erb +8 -0
- data/lib/georgia_recipes/templates/sidekiq.yml.erb +7 -0
- data/lib/georgia_recipes/templates/solr.chef.node.json.erb +11 -0
- data/lib/georgia_recipes/templates/unicorn.rb.erb +36 -0
- data/lib/georgia_recipes/templates/unicorn_init.erb +84 -0
- data/lib/georgia_recipes/unicorn.rb +156 -0
- data/lib/georgia_recipes/version.rb +3 -0
- data/lib/georgia_recipes.rb +5 -0
- metadata +134 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
namespace :mysql do
|
6
|
+
|
7
|
+
desc "Install MySQL"
|
8
|
+
task :install, roles: :app do
|
9
|
+
run "#{sudo} apt-get -y update"
|
10
|
+
run "#{sudo} apt-get -y install mysql-server mysql-server-5.5 mysql-client-5.5 libmysqlclient18 libmysqlclient-dev mysql-common"
|
11
|
+
end
|
12
|
+
after "deploy:install", "mysql:install"
|
13
|
+
|
14
|
+
desc "create a new mysql database and user"
|
15
|
+
task :setup, roles: :app do
|
16
|
+
sql = <<-SQL
|
17
|
+
CREATE DATABASE #{remote_db_name};
|
18
|
+
GRANT ALL PRIVILEGES ON #{remote_db_name}.* TO #{db_user}@localhost IDENTIFIED BY '#{remote_db_password}';
|
19
|
+
SQL
|
20
|
+
|
21
|
+
run "mysql --user=root -p --execute=\"#{sql}\"" do |channel, stream, data|
|
22
|
+
if data =~ /^Enter password:/
|
23
|
+
pass = Capistrano::CLI.password_prompt "Enter database password for root:"
|
24
|
+
channel.send_data "#{pass}\n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
after "deploy:setup", "db:setup"
|
29
|
+
|
30
|
+
desc "Pull mysql database dump from remote server. remote => local"
|
31
|
+
task :pull, roles: :db do
|
32
|
+
run "mkdir -p #{shared_path}/backups"
|
33
|
+
run %Q{mysqldump -u #{remote_db_user} --password=#{remote_db_password} #{remote_db_name} > #{shared_path}/backups/#{database_filename}}
|
34
|
+
get "#{shared_path}/backups/#{database_filename}", "/tmp/#{database_filename}"
|
35
|
+
run "rm #{shared_path}/backups/#{database_filename}"
|
36
|
+
run_locally "mysql -u #{local_db_user} --password=#{local_db_password} #{local_db_name} < /tmp/#{database_filename}"
|
37
|
+
run_locally "rm /tmp/#{database_filename}"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Push mysql database dump to remote server. local => remote"
|
41
|
+
task :push, roles: :db do
|
42
|
+
if are_you_sure?
|
43
|
+
run_locally %Q{mysqldump -u #{local_db_user} --password=#{local_db_password} #{local_db_name} > /tmp/#{database_filename}}
|
44
|
+
upload "/tmp/#{database_filename}", "/tmp/#{database_filename}"
|
45
|
+
run_locally "rm /tmp/#{database_filename}"
|
46
|
+
run "mysql -u #{remote_db_user} --password=#{remote_db_password} #{remote_db_name} < /tmp/#{database_filename}"
|
47
|
+
run "rm /tmp/#{database_filename}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Restart mysql"
|
52
|
+
task :restart, roles: :db do
|
53
|
+
run "sudo service mysql restart"
|
54
|
+
end
|
55
|
+
|
56
|
+
def database_filename
|
57
|
+
@database_filename ||= "#{application}_#{timestamp}.sql"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
set_default(:newrelic_api_key) { ask('What is your NewRelic API key?') }
|
4
|
+
|
5
|
+
namespace :newrelic do
|
6
|
+
desc "Install Newrelic Server Monitor"
|
7
|
+
task :install, roles: :app do
|
8
|
+
run "echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | #{sudo} tee -a /etc/apt/sources.list.d/newrelic.list"
|
9
|
+
run "#{sudo} wget -O- https://download.newrelic.com/548C16BF.gpg | #{sudo} apt-key add -"
|
10
|
+
run "#{sudo} apt-get update"
|
11
|
+
run "#{sudo} apt-get -y install newrelic-sysmond"
|
12
|
+
end
|
13
|
+
after "deploy:install", "newrelic:install"
|
14
|
+
|
15
|
+
task :setup, roles: :app do
|
16
|
+
run "#{sudo} nrsysmond-config --set license_key=#{newrelic_api_key}"
|
17
|
+
restart
|
18
|
+
end
|
19
|
+
|
20
|
+
task :start, roles: :app do
|
21
|
+
run "#{sudo} service newrelic-sysmond start"
|
22
|
+
end
|
23
|
+
|
24
|
+
task :stop, roles: :app do
|
25
|
+
run "#{sudo} service newrelic-sysmond stop"
|
26
|
+
end
|
27
|
+
|
28
|
+
task :restart, roles: :app do
|
29
|
+
stop
|
30
|
+
start
|
31
|
+
end
|
32
|
+
|
33
|
+
task :uninstall, roles: :app do
|
34
|
+
stop
|
35
|
+
run "#{sudo} apt-get remove newrelic-sysmond"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
namespace :nginx do
|
4
|
+
desc "Install latest stable release of nginx"
|
5
|
+
task :install, roles: :web do
|
6
|
+
run "#{sudo} add-apt-repository -y ppa:nginx/stable"
|
7
|
+
run "#{sudo} apt-get -y update"
|
8
|
+
run "#{sudo} apt-get -y install nginx"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Setup nginx configuration for this application"
|
12
|
+
task :setup, roles: :web do
|
13
|
+
template("nginx.erb", "/tmp/nginx_conf")
|
14
|
+
run "#{sudo} mv -u /tmp/nginx_conf /etc/nginx/sites-available/#{application}"
|
15
|
+
run "#{sudo} ln -sf /etc/nginx/sites-available/#{application} /etc/nginx/sites-enabled/#{application}"
|
16
|
+
run "#{sudo} rm -f /etc/nginx/sites-enabled/default"
|
17
|
+
restart
|
18
|
+
end
|
19
|
+
|
20
|
+
%w[start stop restart].each do |command|
|
21
|
+
desc "#{command} nginx"
|
22
|
+
task command, roles: :web do
|
23
|
+
run "#{sudo} service nginx #{command}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
namespace :nodejs do
|
4
|
+
desc "Install the latest relase of Node.js"
|
5
|
+
task :install, roles: :app do
|
6
|
+
run "#{sudo} add-apt-repository -y ppa:chris-lea/node.js"
|
7
|
+
run "#{sudo} apt-get -y update"
|
8
|
+
run "#{sudo} apt-get -y install nodejs"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
set_default(:db_host, "localhost")
|
4
|
+
set_default(:db_user) { (app_var rescue application) }
|
5
|
+
set_default(:db_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
|
6
|
+
set_default(:db_database) { "#{db_user}_production" }
|
7
|
+
set_default(:postgresql_pid) { "/var/run/postgresql/9.1-main.pid" }
|
8
|
+
|
9
|
+
namespace :pg do
|
10
|
+
|
11
|
+
desc "Install the latest stable release of PostgreSQL."
|
12
|
+
task :install, roles: :db, only: {primary: true} do
|
13
|
+
run "#{sudo} add-apt-repository -y ppa:pitti/postgresql"
|
14
|
+
run "#{sudo} apt-get -y update"
|
15
|
+
run "#{sudo} apt-get -y install postgresql libpq-dev"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Generate the database.yml configuration file."
|
19
|
+
task :setup, roles: :app do
|
20
|
+
run "mkdir -p #{shared_path}/config"
|
21
|
+
template "postgresql.yml.erb", "#{shared_path}/config/database.yml"
|
22
|
+
create_user
|
23
|
+
create_db
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Drop & Create database"
|
27
|
+
task :reset, roles: :db do
|
28
|
+
if are_you_sure?
|
29
|
+
deploy.stop
|
30
|
+
run %Q{#{sudo} -u postgres psql -c "drop database #{db_database};"}
|
31
|
+
create_db
|
32
|
+
deploy.start
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Symlink the database.yml file into latest release"
|
37
|
+
task :symlink, roles: :app do
|
38
|
+
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
39
|
+
end
|
40
|
+
after "deploy:finalize_update", "pg:symlink"
|
41
|
+
|
42
|
+
desc "Pull database from remote server"
|
43
|
+
task :pull, roles: :db do
|
44
|
+
run "mkdir -p #{shared_path}/backups"
|
45
|
+
run %Q{#{sudo} -u postgres pg_dump #{db_database} --format=tar > #{shared_path}/backups/#{database_filename}}
|
46
|
+
get "#{shared_path}/backups/#{database_filename}", "/tmp/#{database_filename}"
|
47
|
+
run "rm #{shared_path}/backups/#{database_filename}"
|
48
|
+
run_locally "#{sudo} -u postgres pg_restore /tmp/#{database_filename} --clean --format=tar --dbname=#{db_user}_development"
|
49
|
+
run_locally "rm /tmp/#{database_filename}"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Push database to remote server"
|
53
|
+
task :push, roles: :db do
|
54
|
+
if are_you_sure?
|
55
|
+
run_locally %Q{#{sudo} -u postgres pg_dump #{db_user}_development --format=tar > /tmp/#{database_filename}}
|
56
|
+
upload "/tmp/#{database_filename}", "/tmp/#{database_filename}"
|
57
|
+
run_locally "rm /tmp/#{database_filename}"
|
58
|
+
run "#{sudo} -u postgres pg_restore /tmp/#{database_filename} --clean --format=tar --dbname=#{db_database}"
|
59
|
+
run "rm /tmp/#{database_filename}"
|
60
|
+
deploy.restart
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Seed database with db/seeds.rb"
|
65
|
+
task :seed do
|
66
|
+
run "cd #{current_path} && bundle exec rake db:seed RAILS_ENV=#{rails_env}"
|
67
|
+
end
|
68
|
+
|
69
|
+
### Helpers
|
70
|
+
|
71
|
+
def database_filename
|
72
|
+
@database_filename ||= "#{db_user}_#{timestamp}.sql"
|
73
|
+
end
|
74
|
+
|
75
|
+
def database_table_filename
|
76
|
+
@database_table_filename ||= "#{db_user}_#{table_name}_#{timestamp}.sql"
|
77
|
+
end
|
78
|
+
|
79
|
+
def table_name
|
80
|
+
@table_name ||= Capistrano::CLI.ui.ask "Which remote database table would you like to pull?"
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_user
|
84
|
+
run %Q{#{sudo} -u postgres psql -c "create user #{db_user} with password '#{db_password}';"}
|
85
|
+
end
|
86
|
+
|
87
|
+
def create_db
|
88
|
+
run %Q{#{sudo} -u postgres psql -c "create database #{db_database} owner #{db_user} ENCODING = 'UTF-8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TEMPLATE template0;"}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
set_default :ruby_version, "2.1.1"
|
4
|
+
set_default :rbenv_bootstrap, "bootstrap-ubuntu-12-04"
|
5
|
+
|
6
|
+
namespace :rbenv do
|
7
|
+
desc "Install rbenv, Ruby, and the Bundler gem"
|
8
|
+
task :install, roles: :app do
|
9
|
+
run "#{sudo} apt-get -y update"
|
10
|
+
run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
|
11
|
+
bashrc = <<-BASHRC
|
12
|
+
if [ -d $HOME/.rbenv ]; then
|
13
|
+
export PATH="$HOME/.rbenv/bin:$PATH"
|
14
|
+
eval "$(rbenv init -)"
|
15
|
+
fi
|
16
|
+
BASHRC
|
17
|
+
put bashrc, "/tmp/rbenvrc"
|
18
|
+
run "cat /tmp/rbenvrc ~/.bashrc > ~/.bashrc.tmp"
|
19
|
+
run "mv ~/.bashrc.tmp ~/.bashrc"
|
20
|
+
run %q{export PATH="$HOME/.rbenv/bin:$PATH"}
|
21
|
+
run %q{eval "$(rbenv init -)"}
|
22
|
+
run "rbenv #{rbenv_bootstrap}"
|
23
|
+
ruby.install
|
24
|
+
end
|
25
|
+
|
26
|
+
task :update, roles: :app do
|
27
|
+
run "rbenv update"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
namespace :ruby do
|
32
|
+
task :install do
|
33
|
+
run "rbenv install #{ruby_version}"
|
34
|
+
run "rbenv global #{ruby_version}"
|
35
|
+
run "gem install bundler --no-ri --no-rdoc"
|
36
|
+
run "rbenv rehash"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
namespace :redis do
|
4
|
+
|
5
|
+
desc "Install Redis"
|
6
|
+
task :install, roles: :app do
|
7
|
+
run "#{sudo} apt-get -y update"
|
8
|
+
run "#{sudo} apt-get -y install redis-server"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Start Redis Server"
|
12
|
+
task :start, roles: :app do
|
13
|
+
run "redis-server"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
namespace :sidekiq do
|
3
|
+
|
4
|
+
desc "Generate the sidekiq.yml configuration file."
|
5
|
+
task :setup, roles: :app do
|
6
|
+
run "mkdir -p #{shared_path}/config"
|
7
|
+
template "sidekiq.yml.erb", "#{shared_path}/config/sidekiq.yml"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Symlink the database.yml file into latest release"
|
11
|
+
task :symlink, roles: :app do
|
12
|
+
run "ln -nfs #{shared_path}/config/sidekiq.yml #{release_path}/config/sidekiq.yml"
|
13
|
+
end
|
14
|
+
after "deploy:finalize_update", "sidekiq:symlink"
|
15
|
+
|
16
|
+
desc "Clear Sidekiq Retry Queue"
|
17
|
+
task :clear_queue, roles: :app do
|
18
|
+
run "cd #{current_path} && bundle exec rake sidekiq:clear_queue RAILS_ENV=#{rails_env}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
namespace :solr do
|
4
|
+
|
5
|
+
desc "Install Solr"
|
6
|
+
task :install, roles: :app do
|
7
|
+
run "mkdir -p cookbooks"
|
8
|
+
git_pull_or_clone('cookbooks/hipsnip-solr', 'git@github.com:hipsnip-cookbooks/solr.git')
|
9
|
+
git_pull_or_clone('cookbooks/hipsnip-jetty', 'git@github.com:hipsnip-cookbooks/jetty.git')
|
10
|
+
git_pull_or_clone('cookbooks/java', 'git@github.com:opscode-cookbooks/java.git')
|
11
|
+
git_pull_or_clone('cookbooks/aws', 'git@github.com:opscode-cookbooks/aws.git')
|
12
|
+
git_pull_or_clone('cookbooks/windows', 'git@github.com:opscode-cookbooks/windows.git')
|
13
|
+
git_pull_or_clone('cookbooks/powershell', 'git@github.com:opscode-cookbooks/powershell.git')
|
14
|
+
git_pull_or_clone('cookbooks/chef_handler', 'git@github.com:opscode-cookbooks/chef_handler.git')
|
15
|
+
template "solr.chef.node.json.erb", "node.json"
|
16
|
+
template "chef-solo.rb.erb", "solo.rb"
|
17
|
+
run "#{sudo} chef-solo -j ~/node.json -c ~/solo.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Run once you have a config a solr config for your application
|
21
|
+
task :config, roles: :app do
|
22
|
+
run "#{sudo} cp -R #{current_path}/solr/conf /usr/share/solr/"
|
23
|
+
end
|
24
|
+
|
25
|
+
task :setup, roles: :app do
|
26
|
+
run "#{sudo} chown jetty:jetty -R #{shared_path}/solr/data"
|
27
|
+
run "#{sudo} chmod +w #{shared_path}/solr/data"
|
28
|
+
end
|
29
|
+
|
30
|
+
task :uninstall, roles: :app do
|
31
|
+
solr.stop
|
32
|
+
run "#{sudo} update-rc.d -f jetty remove"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Start Solr"
|
36
|
+
task :start, roles: :app do
|
37
|
+
run "#{sudo} service jetty start"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Stop Solr"
|
41
|
+
task :stop, roles: :app do
|
42
|
+
run "#{sudo} service jetty stop"
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Restart Solr"
|
46
|
+
task :restart, roles: :app do
|
47
|
+
solr.stop
|
48
|
+
solr.start
|
49
|
+
end
|
50
|
+
|
51
|
+
namespace :reindex do
|
52
|
+
|
53
|
+
desc "Reindex the whole database"
|
54
|
+
task :all, :roles => :app do
|
55
|
+
run_with_input "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake sunspot:reindex", /^Are you sure/, 'y'
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'Reindex messages on solr'
|
59
|
+
task :messages, :roles => :app do
|
60
|
+
run "cd #{current_path} && bundle exec rake solr:messages:reindex RAILS_ENV=#{rails_env}"
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'Reindex assets on solr'
|
64
|
+
task :assets, :roles => :app do
|
65
|
+
run "cd #{current_path} && bundle exec rake solr:assets:reindex RAILS_ENV=#{rails_env}"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Reindex pages on solr'
|
69
|
+
task :pages, :roles => :app do
|
70
|
+
run "cd #{current_path} && bundle exec rake solr:pages:reindex RAILS_ENV=#{rails_env}"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
check process sidekiq
|
2
|
+
with pidfile <%= shared_path %>/pids/sidekiq.pid
|
3
|
+
start program = "/usr/bin/sudo su <%= user %> /bin/bash -c 'export PATH="$HOME/.rbenv/bin:$PATH" ; eval "$(rbenv init -)"; cd <%= current_path %>; RAILS_ENV=production bundle exec sidekiq -d -C config/sidekiq.yml -P <%= shared_path %>/pids/sidekiq.pid -L log/sidekiq.log'" with timeout 90 seconds
|
4
|
+
stop program = "/bin/bash -c '/bin/kill -TERM `cat <%= shared_path %>/pids/sidekiq.pid`'" with timeout 180 seconds
|
@@ -0,0 +1,15 @@
|
|
1
|
+
check process <%= application %>_unicorn with pidfile <%= unicorn_pid %>
|
2
|
+
start program = "/etc/init.d/unicorn_<%= application %> start"
|
3
|
+
stop program = "/etc/init.d/unicorn_<%= application %> stop"
|
4
|
+
|
5
|
+
<% unicorn_workers.to_i.times do |n| %>
|
6
|
+
<% pid = unicorn_pid.sub(".pid", ".#{n}.pid") %>
|
7
|
+
check process <%= application %>_unicorn_worker_<%= n %> with pidfile <%= pid %>
|
8
|
+
start program = "/bin/true"
|
9
|
+
stop program = "/usr/bin/test -s <%= pid %> && /bin/kill -QUIT `cat <%= pid %>`"
|
10
|
+
if mem > 200.0 MB for 1 cycles then restart
|
11
|
+
if cpu > 50% for 3 cycles then restart
|
12
|
+
if 5 restarts within 5 cycles then timeout
|
13
|
+
alert webmaster@motioneleven.com only on { pid }
|
14
|
+
if changed pid 2 times within 60 cycles then alert
|
15
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"monit": {
|
3
|
+
"bind_host" : "<%= host %>",
|
4
|
+
"bind_port" : "49555",
|
5
|
+
"allowed_hosts" : ["0.0.0.0/0.0.0.0"],
|
6
|
+
"notify_email" : "<%= ask("What email should monit notify to?") %>",
|
7
|
+
"mail_format" : {
|
8
|
+
"from" : "monit@<%= host %>"
|
9
|
+
}
|
10
|
+
},
|
11
|
+
"run_list" : [
|
12
|
+
"recipe[monit]"
|
13
|
+
]
|
14
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
upstream <%= application %>_unicorn {
|
2
|
+
server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
server {
|
5
|
+
listen 80;
|
6
|
+
server_name <%= host %>;
|
7
|
+
return 301 http://www.<%= host %>$request_uri;
|
8
|
+
}
|
9
|
+
server {
|
10
|
+
listen 80 default;
|
11
|
+
server_name www.<%= host %>;
|
12
|
+
root <%= current_path %>/public;
|
13
|
+
|
14
|
+
location ^~ /assets/ {
|
15
|
+
gzip_static on;
|
16
|
+
expires max;
|
17
|
+
add_header Cache-Control public;
|
18
|
+
}
|
19
|
+
|
20
|
+
try_files $uri/index.html $uri @unicorn;
|
21
|
+
location @unicorn {
|
22
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
23
|
+
proxy_set_header Host $http_host;
|
24
|
+
proxy_redirect off;
|
25
|
+
proxy_pass http://<%= application %>_unicorn;
|
26
|
+
}
|
27
|
+
|
28
|
+
if (-f $document_root/system/maintenance.html) {
|
29
|
+
return 503;
|
30
|
+
}
|
31
|
+
error_page 503 @maintenance;
|
32
|
+
location @maintenance {
|
33
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
34
|
+
break;
|
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,36 @@
|
|
1
|
+
working_directory "<%= current_path %>"
|
2
|
+
pid "<%= unicorn_pid %>"
|
3
|
+
stderr_path "<%= unicorn_log %>"
|
4
|
+
stdout_path "<%= unicorn_log %>"
|
5
|
+
|
6
|
+
listen "/tmp/unicorn.<%= application %>.sock"
|
7
|
+
worker_processes <%= unicorn_workers %>
|
8
|
+
timeout 30
|
9
|
+
|
10
|
+
preload_app true
|
11
|
+
|
12
|
+
before_fork do |server, worker|
|
13
|
+
# Disconnect since the database connection will not carry over
|
14
|
+
if defined? ActiveRecord::Base
|
15
|
+
ActiveRecord::Base.connection.disconnect!
|
16
|
+
end
|
17
|
+
|
18
|
+
# Quit the old unicorn process
|
19
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
20
|
+
if File.exists?(old_pid) && server.pid != old_pid
|
21
|
+
begin
|
22
|
+
Process.kill("QUIT", File.read(old_pid).to_i)
|
23
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
24
|
+
# someone else did our job for us
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
after_fork do |server, worker|
|
30
|
+
# Start up the database connection again in the worker
|
31
|
+
if defined?(ActiveRecord::Base)
|
32
|
+
ActiveRecord::Base.establish_connection
|
33
|
+
end
|
34
|
+
child_pid = server.config[:pid].sub(".pid", ".#{worker.nr}.pid")
|
35
|
+
system("echo #{Process.pid} > #{child_pid}")
|
36
|
+
end
|