From 5ade7e4101d05d8bd8a88cb9022c6ea7604299d4 Mon Sep 17 00:00:00 2001 From: Ismail Akbudak Date: Fri, 21 Aug 2015 11:27:59 +0300 Subject: [PATCH] add new features --- lib/cybele/app_builder.rb | 11 +++++++---- lib/cybele/generators/app_generator.rb | 6 +++--- templates/config/database.yml.erb | 10 +++++++++- templates/config/deploy.rb | 17 ++++++++++------- templates/cybele_Gemfile | 6 +++++- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index 0e455dc..9cc021f 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -314,6 +314,8 @@ def setup_capistrano_settings inject_into_file 'Capfile', :after => "require 'capistrano/deploy'\n" do <<-RUBY require 'capistrano/rails' require 'capistrano/bundler' +require 'sshkit/sudo' +require 'capistrano/maintenance' RUBY end @@ -321,19 +323,20 @@ def setup_capistrano_settings 'server "example.com", user: "#{local_user}", roles: %w{app db web}, primary: true #set :port, 2222 set :rails_env, "production" -set :branch, "master"' +set :branch, "master" +set :project_domain, "example.com"' end append_to_file 'config/deploy/staging.rb' do 'server "staging.example.com", user: "#{local_user}", roles: %w{app db web}, primary: true #set :port, 2222 set :rails_env, "staging" -set :branch, "develop"' +set :branch, "develop" +set :project_domain, "staging.example.com"' end end # Nor using - def setup_recipes - run 'rm config/deploy.rb' + def setup_recipes generate 'recipes_matic:install' end diff --git a/lib/cybele/generators/app_generator.rb b/lib/cybele/generators/app_generator.rb index 3cedcc2..2332f95 100644 --- a/lib/cybele/generators/app_generator.rb +++ b/lib/cybele/generators/app_generator.rb @@ -210,9 +210,9 @@ def setup_capistrano_settings build :setup_capistrano_settings end - # def setup_recipes - # build :setup_recipes - # end + def setup_recipes + build :setup_recipes + end def setup_secret_token say 'Setup secret token' diff --git a/templates/config/database.yml.erb b/templates/config/database.yml.erb index db478d5..ecf6e1e 100644 --- a/templates/config/database.yml.erb +++ b/templates/config/database.yml.erb @@ -10,4 +10,12 @@ development: &default test: <<: *default - database: <%= app_name %>_test \ No newline at end of file + database: <%= app_name %>_test + +production: + <<: *default + database: <%= app_name %>_production + +staging: + <<: *default + database: <%= app_name %>_staging \ No newline at end of file diff --git a/templates/config/deploy.rb b/templates/config/deploy.rb index b17dcab..b3266aa 100644 --- a/templates/config/deploy.rb +++ b/templates/config/deploy.rb @@ -10,12 +10,11 @@ # Default branch is :master # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp -# Default deploy_to directory is /var/www/blog2 -# set :deploy_to, '/var/www/blog2' +# Default deploy_to directory is /var/www/blog2 set :deploy_to, "/home/#{local_user}/apps/#{fetch(:application)}" # Default value for :scm is :git -# set :scm, :git +set :scm, :git # Default value for :format is :pretty # set :format, :pretty @@ -24,13 +23,13 @@ # set :log_level, :debug # Default value for :pty is false -# set :pty, true +set :pty, true # Default value for :linked_files is [] -# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml') +set :linked_files, fetch(:linked_files, []).push('config/database.yml') # Default value for linked_dirs is [] -# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') +set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') # Default value for default_env is {} # set :default_env, { path: "/opt/ruby/bin:$PATH" } @@ -39,7 +38,11 @@ # Default value for keep_releases is 5 # set :keep_releases, 5 -namespace :deploy do +# Look our recipes +# https://github.com/lab2023/recipes_matic +load 'config/deploy/recipes/base.rb' + +namespace :deploy do after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do diff --git a/templates/cybele_Gemfile b/templates/cybele_Gemfile index 1a4b2ea..a7c636e 100644 --- a/templates/cybele_Gemfile +++ b/templates/cybele_Gemfile @@ -17,6 +17,9 @@ gem 'capistrano', '~> 3.4.0' group :development do gem 'capistrano-rails', '~> 1.1', require: false gem 'capistrano-bundler', '~> 1.1', require: false + gem 'sshkit-sudo', require: false + gem 'capistrano-maintenance', '~> 1.0', require: false + gem 'recipes_matic', git: 'git@github.com:lab2023/recipes_matic.git', branch: 'feature/upgrade' end gem 'unicorn', '~> 4.9.0' gem 'exception_notification', '~> 4.1.1' @@ -34,7 +37,7 @@ gem 'jquery-rails', '~> 4.0.4' gem 'turbolinks', '~> 2.5.3' gem 'haml', '~> 4.0.2' gem 'haml-rails', '0.9.0' -gem 'hierapolis-rails', '~> 1.1.0' +gem 'hierapolis-rails', git: 'git@github.com:lab2023/recipes_matic.git', branch: 'feature/improvement' gem 'breadcrumbs_on_rails', '~> 2.3.1' gem 'blankable', '~> 0.2.0' @@ -55,6 +58,7 @@ group :development, :test do gem 'better_errors' gem 'letter_opener' gem 'rspec-rails' + gem 'binding_of_caller' gem 'katip' gem 'capybara' gem 'bullet'