ricodigo-capistrano-recipes 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -32,7 +32,7 @@ def install_packages(ssh)
32
32
  packages = %w[
33
33
  bind9 build-essential ufw libreadline6-dev git-core
34
34
  libxslt1-dev libxml2-dev libssl-dev nginx mongodb-10gen curl
35
- libcurl4-openssl-dev graphicsmagick
35
+ libcurl4-openssl-dev graphicsmagick openjdk-6-jre-headless libsasl2-dev
36
36
  ]
37
37
 
38
38
  ssh.exec! "sudo apt-get install -y --force-yes #{packages.join(" ")}" do |channel, stream, data|
@@ -0,0 +1,37 @@
1
+ queue = "<%= magent_queue %>"
2
+ identity = "#{queue}-#{Socket.gethostname.split('.')[0]}"
3
+ app_name = 'magent'
4
+ rails_root = "<%= deploy_to %>/current"
5
+ rails_env = "<%= environment %>"
6
+ log_file = "#{rails_root}/log/magent_bluepill.log"
7
+ magent_bin = "/usr/bin/env RAILS_ENV=#{rails_env} bundle exec magent"
8
+ magent_pid_path = "#{rails_root}/tmp/pids"
9
+ magent_pid_file = "#{magent_pid_path}/magent.#{identity}.pid"
10
+ grace_time = <%= magent_grace_time %>
11
+
12
+ magent_start_cmd = "#{magent_bin} -d -Q #{queue} -l #{rails_root}/log -P #{magent_pid_path} start"
13
+ magent_stop_cmd = "#{magent_bin} -d -Q #{queue} -l #{rails_root}/log -P #{magent_pid_path} stop"
14
+ magent_restart_cmd = "#{magent_bin} -d -Q #{queue} -l #{rails_root}/log -P #{magent_pid_path} restart"
15
+
16
+
17
+ puts ">> Starting #{app_name} bluepill with RAILS_ROOT=#{rails_root} and RAILS_ENV=#{rails_env}"
18
+
19
+ Bluepill.application(app_name, :log_file => log_file) do |app|
20
+ app.process("magent-#{queue}") do |process|
21
+ process.pid_file = magent_pid_file
22
+ process.working_dir = rails_root
23
+
24
+ process.start_command = magent_start_cmd
25
+ process.stop_command = magent_stop_cmd
26
+ process.restart_command = magent_restart_cmd
27
+
28
+ process.start_grace_time = grace_time
29
+ process.stop_grace_time = grace_time
30
+ process.restart_grace_time = grace_time
31
+
32
+ process.uid = "app"
33
+ process.gid = "app"
34
+
35
+ process.checks :mem_usage, :every => 15.seconds, :below => 165.megabytes, :times => [3,4], :fires => :stop
36
+ end
37
+ end
@@ -15,8 +15,8 @@ server {
15
15
 
16
16
  # path for static files
17
17
  root <%= deploy_to %>/current/public;
18
- access_log <%= deploy_to %>/current/log/nginx.access.log main;
19
- error_log <%= deploy_to %>/current/log/nginx.error.log info;
18
+ access_log <%= deploy_to %>/current/log/nginx.access.log;
19
+ error_log <%= deploy_to %>/current/log/nginx.error.log;
20
20
 
21
21
  # this rewrites all the requests to the maintenance.html
22
22
  # page if it exists in the doc root. This is for capistrano's
@@ -120,8 +120,8 @@ server {
120
120
  client_max_body_size 50M;
121
121
 
122
122
  root <%= deploy_to %>/current/public;
123
- access_log <%= deploy_to %>/current/log/nginx.access.log main;
124
- error_log <%= deploy_to %>/current/log/nginx.error.log info;
123
+ access_log <%= deploy_to %>/current/log/nginx.access.log;
124
+ error_log <%= deploy_to %>/current/log/nginx.error.log;
125
125
 
126
126
  # this rewrites all the requests to the maintenance.html
127
127
  # page if it exists in the doc root. This is for capistrano's
@@ -0,0 +1,36 @@
1
+ app_name = 'FIXME'
2
+ grace_time = 120
3
+ rails_root = '<%= deploy_to %>/current'
4
+ rails_env = '<%= environment %>'
5
+ log_file = "#{rails_root}/log/#{app_name}_bluepill.log"
6
+ cmd_bin = "/usr/bin/env RAILS_ENV=#{rails_env} bundle exec script/#{app_name}"
7
+ cmd_pid = "#{rails_root}/tmp/pids/#{app_name}.pid"
8
+
9
+ cmd_start_cmd = "#{cmd_bin}"
10
+ cmd_stop_cmd = "kill -QUIT {{PID}}"
11
+ cmd_restart_cmd = "bash -c '#{cmd_stop_cmd} && #{cmd_start_cmd}'"
12
+
13
+
14
+ puts ">> Starting #{app_name} bluepill with RAILS_ROOT=#{rails_root} and RAILS_ENV=#{rails_env}"
15
+
16
+ Bluepill.application(app_name, :log_file => log_file) do |app|
17
+ app.process("cmd-#{app_name}") do |process|
18
+ process.pid_file = cmd_pid
19
+ process.daemonize = true
20
+ process.working_dir = rails_root
21
+
22
+ process.start_command = cmd_start_cmd
23
+ process.stop_command = cmd_stop_cmd
24
+ process.restart_command = cmd_restart_cmd
25
+
26
+ process.start_grace_time = grace_time
27
+ process.stop_grace_time = grace_time
28
+ process.restart_grace_time = grace_time
29
+
30
+ process.uid = "app"
31
+ process.gid = "app"
32
+
33
+ process.checks :mem_usage, :every => 15.seconds, :below => 165.megabytes, :times => [3,4], :fires => :stop
34
+ process.checks :cpu_usage, :every => 15.seconds, :below => 90, :times => [3,4], :fires => :stop
35
+ end
36
+ end
@@ -1,13 +1,18 @@
1
1
  Capistrano::Configuration.instance.load do
2
- set(:bluepill_local_config) { "#{templates_path}/app.bluepill.erb" } unless exists?(:nginx_local_config)
3
- set(:bluepill_remote_config) { "#{shared_path}/config/pills/#{application}.pill" } unless exists?(:nginx_remote_config)
2
+ set(:bluepill_local_config) { "#{templates_path}/app.bluepill.erb" } unless exists?(:bluepill_local_config)
3
+ set(:bluepill_remote_config) { "#{shared_path}/config/pills/#{application}.pill" } unless exists?(:bluepill_remote_config)
4
4
 
5
5
  namespace :bluepill do
6
- desc "|capistrano-recipes| Parses and uploads nginx configuration for this app."
6
+ desc "|capistrano-recipes| Parses and uploads bluepill configuration for this app."
7
7
  task :setup, :roles => :app , :except => { :no_release => true } do
8
8
  generate_config(bluepill_local_config, bluepill_remote_config)
9
9
  end
10
10
 
11
+ desc "|capistrano-recipes| Parses and uploads a bluepill template."
12
+ task :template, :roles => :app , :except => { :no_release => true } do
13
+ generate_config("#{templates_path}/template.bluepill.erb", "#{shared_path}/config/pills/template.pill")
14
+ end
15
+
11
16
  desc "|capistrano-recipes| Install the bluepill monitoring tool"
12
17
  task :install, :roles => [:app] do
13
18
  sudo "gem install bluepill"
@@ -1,15 +1,44 @@
1
1
  Capistrano::Configuration.instance.load do
2
+ set(:magent_queue, :default) unless exists?(:magent_queue)
3
+ set(:magent_grace_time, 120) unless exists?(:magent_grace_time)
4
+ set(:magent_local_config) { "#{templates_path}/magent.bluepill.erb" } unless exists?(:magent_local_config)
5
+ set(:magent_remote_config) { "#{shared_path}/config/pills/magent.pill" } unless exists?(:magent_remote_config)
6
+
2
7
  namespace :magent do
8
+ desc "Configure magent pill"
9
+ task :setup do
10
+ generate_config(magent_local_config, magent_remote_config)
11
+ end
12
+
13
+ desc "Init magent with bluepill"
14
+ task :init do
15
+ rvmsudo "bluepill load #{magent_remote_config}"
16
+ end
17
+
18
+ desc "Start magent with bluepill"
3
19
  task :start do
4
- run "export RAILS_ENV=#{rails_env}; cd #{current_path}; bundle exec magent -d -Q default -l #{current_path}/log -P #{current_path}/tmp/pids start; true"
20
+ rvmsudo "bluepill magent start"
5
21
  end
6
22
 
23
+ desc "Restart magent with bluepill"
7
24
  task :restart do
8
- run "export RAILS_ENV=#{rails_env}; cd #{current_path}; bundle exec magent -d -Q default -l #{current_path}/log -P #{current_path}/tmp/pids restart; true"
25
+ rvmsudo "bluepill magent restart"
9
26
  end
10
27
 
28
+ desc "Stop magent with bluepill"
11
29
  task :stop do
12
- run "export RAILS_ENV=#{rails_env}; cd #{current_path}; bundle exec magent -d -Q default -l #{current_path}/log -P #{current_path}/tmp/pids stop; true"
30
+ rvmsudo "bluepill magent stop"
31
+ end
32
+
33
+ desc "Display the bluepill status"
34
+ task :status do
35
+ rvmsudo "bluepill magent status"
36
+ end
37
+
38
+ desc "Stop magent and quit bluepill"
39
+ task :quit do
40
+ rvmsudo "bluepill magent stop"
41
+ rvmsudo "bluepill magent quit"
13
42
  end
14
43
  end
15
44
  end
data/lib/recipes/nginx.rb CHANGED
@@ -8,7 +8,7 @@ Capistrano::Configuration.instance.load do
8
8
 
9
9
  # Path to where your remote config will reside (I use a directory sites inside conf)
10
10
  set(:nginx_remote_config) do
11
- "#{nginx_path_prefix}/conf/sites/#{application}.conf"
11
+ "#{nginx_path_prefix}/conf.d/#{application}.site.conf"
12
12
  end unless exists?(:nginx_remote_config)
13
13
 
14
14
  # Nginx tasks are not *nix agnostic, they assume you're using Debian/Ubuntu.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ricodigo-capistrano-recipes}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David A. Cuadrado"]
12
- s.date = %q{2011-05-25}
12
+ s.date = %q{2011-05-26}
13
13
  s.default_executable = %q{ricodigo-install-server}
14
14
  s.description = %q{our capistrano recipes. forked from capistrano-recipes}
15
15
  s.email = %q{krawek@gmail.com}
@@ -28,7 +28,9 @@ Gem::Specification.new do |s|
28
28
  "VERSION",
29
29
  "bin/ricodigo-install-server",
30
30
  "generators/app.bluepill.erb",
31
+ "generators/magent.bluepill.erb",
31
32
  "generators/nginx.conf.erb",
33
+ "generators/template.bluepill.erb",
32
34
  "generators/unicorn.rb.erb",
33
35
  "lib/helpers.rb",
34
36
  "lib/recipes/application.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - David A. Cuadrado
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-25 00:00:00 -05:00
17
+ date: 2011-05-26 00:00:00 -05:00
18
18
  default_executable: ricodigo-install-server
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -174,7 +174,9 @@ files:
174
174
  - VERSION
175
175
  - bin/ricodigo-install-server
176
176
  - generators/app.bluepill.erb
177
+ - generators/magent.bluepill.erb
177
178
  - generators/nginx.conf.erb
179
+ - generators/template.bluepill.erb
178
180
  - generators/unicorn.rb.erb
179
181
  - lib/helpers.rb
180
182
  - lib/recipes/application.rb
@@ -205,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
207
  requirements:
206
208
  - - ">="
207
209
  - !ruby/object:Gem::Version
208
- hash: -2322525543932527939
210
+ hash: 2507973693654577722
209
211
  segments:
210
212
  - 0
211
213
  version: "0"