From 8d3fc8f7f6ecf3c4721e0b7d0d5bc5ec7a046d5a Mon Sep 17 00:00:00 2001 From: "Gordon B. Isnor" Date: Tue, 2 Sep 2014 18:25:51 -0300 Subject: [PATCH 1/5] Needed to set bundle command Signed-off-by: Gordon B. Isnor --- Capfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Capfile b/Capfile index ab4e97d..fb3365a 100644 --- a/Capfile +++ b/Capfile @@ -1,4 +1,7 @@ # Load DSL and Setup Up Stages + +set :bundle_cmd, "/usr/local/rbenv/shims/bundle" + require 'capistrano/setup' # Includes default deployment tasks From 32c372e6b1700e6d7edf17d9cf898a293cfdeb81 Mon Sep 17 00:00:00 2001 From: "Gordon B. Isnor" Date: Tue, 2 Sep 2014 18:29:13 -0300 Subject: [PATCH 2/5] Ruby version discrepancy; secrets.yml issue - TalkingQuickly/rails-server-template uses rbenv 2.1.2, but capistrano-3-rails-template is specifying 2.1.1 - discrepancy was an issue; - lack of secrets.yml caused an issue --- config/deploy.rb | 5 +++-- config/deploy/shared/secrets.example.yml.erb | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 config/deploy/shared/secrets.example.yml.erb diff --git a/config/deploy.rb b/config/deploy.rb index 8ecdfb3..e938ee4 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -7,7 +7,7 @@ # setup rbenv. set :rbenv_type, :system -set :rbenv_ruby, '2.1.1' +set :rbenv_ruby, '2.1.2' set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" set :rbenv_map_bins, %w{rake gem bundle ruby rails} @@ -15,7 +15,7 @@ set :keep_releases, 5 # files we want symlinking to specific entries in shared -set :linked_files, %w{config/database.yml} +set :linked_files, %w{config/database.yml config/secrets.yml} # dirs we want symlinking to shared set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} @@ -30,6 +30,7 @@ set(:config_files, %w( nginx.conf database.example.yml + secrets.example.yml log_rotation monit unicorn.rb diff --git a/config/deploy/shared/secrets.example.yml.erb b/config/deploy/shared/secrets.example.yml.erb new file mode 100644 index 0000000..f5a1df7 --- /dev/null +++ b/config/deploy/shared/secrets.example.yml.erb @@ -0,0 +1,3 @@ +<%= fetch(:rails_env) %>: + secret_key_base: xxx + From 6c96ad093e5dd4514a1c10f7425e1cfa66e36bd9 Mon Sep 17 00:00:00 2001 From: "Gordon B. Isnor" Date: Tue, 2 Sep 2014 18:29:54 -0300 Subject: [PATCH 3/5] updated gem versions, had issues with those specified in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d90e501..a8c7bf2 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ book Reliably Deploying Rails Applications available on Leanpub: You should have the following in your Gemfile: - gem 'capistrano', '~> 3.1.0' + gem 'capistrano', '~> 3.2.1' # rails specific capistrano funcitons - gem 'capistrano-rails', '~> 1.1.0' + gem 'capistrano-rails', '~> 1.1.1' # integrate bundler with capistrano gem 'capistrano-bundler' From 4f3be8c917aec7892b689ecfe2d2b96379ea1b45 Mon Sep 17 00:00:00 2001 From: "Gordon B. Isnor" Date: Fri, 12 Sep 2014 16:23:50 -0300 Subject: [PATCH 4/5] thinking sphinx --- config/deploy.rb | 22 +++++++++++++++++++- config/deploy/shared/monit.sphinx.erb | 9 ++++++++ config/deploy/shared/start_sphinx.erb.sh | 7 +++++++ config/deploy/shared/stop_sphinx.erb.sh | 4 ++++ config/deploy/shared/thinking_sphinx.yml.erb | 3 +++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 config/deploy/shared/monit.sphinx.erb create mode 100644 config/deploy/shared/start_sphinx.erb.sh create mode 100644 config/deploy/shared/stop_sphinx.erb.sh create mode 100644 config/deploy/shared/thinking_sphinx.yml.erb diff --git a/config/deploy.rb b/config/deploy.rb index e938ee4..84c1a95 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,3 +1,5 @@ +require 'thinking_sphinx/capistrano' + set :application, 'app_name' set :deploy_user, 'deploy' @@ -15,7 +17,7 @@ set :keep_releases, 5 # files we want symlinking to specific entries in shared -set :linked_files, %w{config/database.yml config/secrets.yml} +set :linked_files, %w{config/database.yml config/secrets.yml config/thinking_sphinx.yml} # dirs we want symlinking to shared set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} @@ -31,8 +33,12 @@ nginx.conf database.example.yml secrets.example.yml + thinking_sphinx.yml log_rotation monit + monit.sphinx + start_sphinx + stop_sphinx unicorn.rb unicorn_init.sh )) @@ -41,6 +47,8 @@ # by deploy:setup_config set(:executable_config_files, %w( unicorn_init.sh + start_sphinx + stop_sphinx )) @@ -65,6 +73,18 @@ { source: "monit", link: "/etc/monit/conf.d/{{full_app_name}}.conf" + }, + { + source: "monit.sphinx", + link: "/etc/monit/conf.d/sphinx.conf" + }, + { + source: "start_sphinx", + link: "/etc/init.d/start_sphinx" + }, + { + source: "stop_sphinx", + link: "/etc/init.d/stop_sphinx" } ]) diff --git a/config/deploy/shared/monit.sphinx.erb b/config/deploy/shared/monit.sphinx.erb new file mode 100644 index 0000000..6c43032 --- /dev/null +++ b/config/deploy/shared/monit.sphinx.erb @@ -0,0 +1,9 @@ +<% application = fetch(:application) %> + +check process searchd + with pidfile <%= deploy_to %>/shared/tmp/pids/production.sphinx.pid + start program = "/etc/init.d/start_sphinx" + stop program = "/etc/init.d/stop_sphinx" + + + \ No newline at end of file diff --git a/config/deploy/shared/start_sphinx.erb.sh b/config/deploy/shared/start_sphinx.erb.sh new file mode 100644 index 0000000..6575aec --- /dev/null +++ b/config/deploy/shared/start_sphinx.erb.sh @@ -0,0 +1,7 @@ +#! /bin/sh + +cd <%= fetch(:deploy_to) %>/current && RAILS_ENV=production bundle exec rake ts:index +cd <%= fetch(:deploy_to) %>/current && RAILS_ENV=production bundle exec rake ts:start > log/sphinx.log 2>&1 + + + diff --git a/config/deploy/shared/stop_sphinx.erb.sh b/config/deploy/shared/stop_sphinx.erb.sh new file mode 100644 index 0000000..ba5b2de --- /dev/null +++ b/config/deploy/shared/stop_sphinx.erb.sh @@ -0,0 +1,4 @@ +#!/bin/bash +export PATH="$PATH:/usr/local/bin" + +cd <%= fetch(:deploy_to) %>/current && RAILS_ENV=production bundle exec rake ts:stop > log/sphinx.log 2>&1 \ No newline at end of file diff --git a/config/deploy/shared/thinking_sphinx.yml.erb b/config/deploy/shared/thinking_sphinx.yml.erb new file mode 100644 index 0000000..116c0ad --- /dev/null +++ b/config/deploy/shared/thinking_sphinx.yml.erb @@ -0,0 +1,3 @@ +production: + pid_file: <%= fetch(:deploy_to) %>/shared/tmp/pids/production.sphinx.pid + From 58adff84e831621d0722107499c14ff7f3237152 Mon Sep 17 00:00:00 2001 From: "Gordon B. Isnor" Date: Fri, 12 Sep 2014 16:50:45 -0300 Subject: [PATCH 5/5] sphinx notes --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a8c7bf2..5f01011 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ This is a sample configuration for deploying Ruby on Rails applications with Cap See -for a tutorial on usage. +for a tutorial on usage. + Or for more details, this is also the example configuration used in the book Reliably Deploying Rails Applications available on Leanpub: @@ -32,3 +33,12 @@ You should have the following in your Gemfile: # Use Unicorn as our app server gem 'unicorn' +## Additions + +I have added Sphinx to this. So add to gemfile: + + gem 'thinking-sphinx', '~> 3.1.0' + gem 'mysql2' + +gordonbisnor fork is also referencing the following article: and the forked Rails server template: +