recipes_matic 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26ac98a3eb644b6f3ad03253deae765d7e617411
4
- data.tar.gz: f9c124f04f246b8fe17c200df8360896f1f42373
3
+ metadata.gz: 07e253404c7f46d4e6e00bc1b2508042457ac8e9
4
+ data.tar.gz: 6c8306917f444e4916548a449bd3036f8428f22b
5
5
  SHA512:
6
- metadata.gz: 0e7c6d38fdd9dba8d13f4cbd28a9fbbf1d0824b69fefa7b6a79536c0397b5467cb669318b0a1a6f3562ed6fd33d7d1aeb19bcd1a5b4c15bbbb5aa3bf6186685a
7
- data.tar.gz: f3df766834fc7f8871c5c1fdb4240d7c1b8a18e08071d3ce8817293253a12548562f60e163bf5d4733f0c868cdf92c7460f025d41f2ed2df414b952b02272051
6
+ metadata.gz: 49ddd3edde145e3c2f0575d7787c71d4b2e871015a94a4cef7c75490c6cd5b77bb95d2e2c06b78cac11877d0e754b02f34141ea16f29053c70532193e3e15b0c
7
+ data.tar.gz: 5b4f40bf613f2c016fdfc71ccaa80caa4af26966785c50ad65d0752db687efe8aa141d0c7c4f1ecb5e3dd5bbfd3855d0e9ce6b527c097c1a26c78ff2bcb3c176
@@ -1,8 +1,18 @@
1
1
 
2
2
  #### [Current]
3
-
4
-
5
- #### v1.2.0
3
+ * [f3d81e0](../../commit/f3d81e0) - __(Ismail Akbudak)__ update version v1.3.0
4
+ * [9e3f191](../../commit/9e3f191) - __(Ismail Akbudak)__ fix deploy logic
5
+ * [d1dfd72](../../commit/d1dfd72) - __(İsmail)__ Rename example_Capfile.rb to example_Capfile
6
+ * [5b8ee1b](../../commit/5b8ee1b) - __(İsmail)__ Update README.md
7
+ * [5e1023b](../../commit/5e1023b) - __(İsmail)__ Create example_Capfile.rb
8
+ * [be021d1](../../commit/be021d1) - __(İsmail)__ Update README.md
9
+ * [1097dfd](../../commit/1097dfd) - __(İsmail)__ Update README.md
10
+ * [9995d5a](../../commit/9995d5a) - __(İsmail)__ Create example_deploy.rb
11
+ * [01812de](../../commit/01812de) - __(Ismail Akbudak)__ add upload directories task
12
+ * [a3694f9](../../commit/a3694f9) - __(Ismail Akbudak)__ fix error
13
+ * [711fbbe](../../commit/711fbbe) - __(Ismail Akbudak)__ improve postgresql tasks
14
+ * [0ab83a1](../../commit/0ab83a1) - __(Ismail Akbudak)__ add rails tasks
15
+ * [6580920](../../commit/6580920) - __(Tayfun Öziş ERİKAN)__ Development dependency problem was solved
6
16
  * [e623c33](../../commit/e623c33) - __(Tayfun Öziş ERİKAN)__ Bump version v1.2.0
7
17
  * [ea6110e](../../commit/ea6110e) - __(Tayfun Öziş ERİKAN)__ Improvements were done - LICENSE file was updated - README was updated - Gemspecs were updated
8
18
  * [fcec848](../../commit/fcec848) - __(Ismail Akbudak)__ add maintenance mode for zero down time deploy
data/README.md CHANGED
@@ -46,10 +46,14 @@ Add this line to end of `config/deploy.rb` file
46
46
  ```ruby
47
47
  load 'config/deploy/recipes/base.rb'
48
48
  ```
49
+ Also look our [example config/deploy.rb file](example_deploy.rb)
50
+ [example Capfile file](example_Capfile)
49
51
 
50
52
  If you want to prepare your server, run the following command
53
+
51
54
  For production :
52
55
  `bundle exec cap production deploy:prepare`
56
+
53
57
  For staging :
54
58
  `bundle exec cap staging deploy:prepare`
55
59
 
@@ -0,0 +1,31 @@
1
+ # Load DSL and set up stages
2
+ require 'capistrano/setup'
3
+
4
+ # Include default deployment tasks
5
+ require 'capistrano/deploy'
6
+ require 'capistrano/rails'
7
+ require 'capistrano/bundler'
8
+ require 'sshkit/sudo'
9
+ require 'capistrano/maintenance'
10
+
11
+ # Include tasks from other gems included in your Gemfile
12
+ #
13
+ # For documentation on these, see for example:
14
+ #
15
+ # https://github.com/capistrano/rvm
16
+ # https://github.com/capistrano/rbenv
17
+ # https://github.com/capistrano/chruby
18
+ # https://github.com/capistrano/bundler
19
+ # https://github.com/capistrano/rails
20
+ # https://github.com/capistrano/passenger
21
+ #
22
+ # require 'capistrano/rvm'
23
+ # require 'capistrano/rbenv'
24
+ # require 'capistrano/chruby'
25
+ # require 'capistrano/bundler'
26
+ # require 'capistrano/rails/assets'
27
+ # require 'capistrano/rails/migrations'
28
+ # require 'capistrano/passenger'
29
+
30
+ # Load custom tasks from `lib/capistrano/tasks` if you have any defined
31
+ Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
@@ -0,0 +1,43 @@
1
+ # config valid only for current version of Capistrano
2
+ lock '3.4.0'
3
+
4
+ set :application, 'appname'
5
+ set :local_user, 'deploy'
6
+ set :stages, %w(staging production)
7
+ set :default_stage, 'production'
8
+ set :repo_url, "git@github.com:username/#{fetch(:application)}.git"
9
+
10
+ # Default branch is :master
11
+ # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
12
+
13
+ # Default deploy_to directory is /var/www/blog2
14
+ set :deploy_to, "/home/#{fetch(:local_user)}/apps/#{fetch(:application)}"
15
+
16
+ # Default value for :scm is :git
17
+ set :scm, :git
18
+
19
+ # Default value for :format is :pretty
20
+ # set :format, :pretty
21
+
22
+ # Default value for :log_level is :debug
23
+ # set :log_level, :debug
24
+
25
+ # Default value for :pty is false
26
+ set :pty, true
27
+
28
+ # Default value for :linked_files is []
29
+ set :linked_files, fetch(:linked_files, []).push('config/database.yml')
30
+
31
+ # Default value for linked_dirs is []
32
+ set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/upload', 'public/images', 'public/seat_images')
33
+
34
+ # Default value for default_env is {}
35
+ # set :default_env, { path: "/opt/ruby/bin:$PATH" }
36
+ set :default_env, { path: '$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH' }
37
+
38
+ # Default value for keep_releases is 5
39
+ # set :keep_releases, 5
40
+
41
+ # Look our recipes
42
+ # https://github.com/lab2023/recipes_matic
43
+ load 'config/deploy/recipes/base.rb'
@@ -2,6 +2,8 @@ set :shared_path, "#{fetch(:deploy_to)}/shared"
2
2
  set :current_path, "#{fetch(:deploy_to)}/current"
3
3
  set :postgresql_pid, "/var/run/postgresql/9.3-main.pid"
4
4
  set :unicorn_pid, "#{fetch(:current_path)}/tmp/pids/unicorn.pid"
5
+ set :postgresql_host, 'localhost'
6
+ set :postgresql_port, '5432'
5
7
  set :run_path, '$HOME/.rbenv/shims/'
6
8
  set :maintenance_template_path, File.expand_path('../templates/maintenance.html.erb', __FILE__)
7
9
  # local user group on server. We use deploy group
@@ -38,12 +40,14 @@ namespace :deploy do
38
40
  after 'deploy', 'deploy:cleanup_assets'
39
41
  before 'unicorn:upgrade', 'maintenance:enable'
40
42
  after 'deploy', 'unicorn:upgrade'
41
- after 'unicorn:upgrade', 'maintenance:disable'
43
+ after 'unicorn:upgrade', 'unicorn:stop'
44
+ after 'unicorn:stop', 'unicorn:start'
45
+ after 'unicorn:start', 'maintenance:disable'
42
46
 
43
47
  desc <<-DESC
44
48
  Prepare environment for first deploy. You can use this command for first deploy
45
49
  This command invokes
46
- - postgresql:create_database_file
50
+ - db:create_file
47
51
  - deploy(starting updating publishing finishing)
48
52
  - postgresql:setup
49
53
  - nginx:setup
@@ -54,7 +58,7 @@ namespace :deploy do
54
58
  DESC
55
59
  task :prepare do
56
60
  puts 'prepare'
57
- invoke 'postgresql:create_database_file'
61
+ invoke 'db:create_file'
58
62
  %w{starting updating publishing finishing}.each do |task|
59
63
  invoke "deploy:#{task}"
60
64
  end
@@ -1,4 +1,4 @@
1
- Backup::Model.new(:<%= fetch(:application) %>, '<%= fetch(:application) %> backup') do
1
+ Backup::Model.new(:<%= fetch(:application) %>, '<%= fetch(:application) %> - <% fetch(:rails_env) %> backup') do
2
2
  ##
3
3
  # Split [Splitter]
4
4
  #
@@ -35,18 +35,23 @@ Backup::Model.new(:<%= fetch(:application) %>, '<%= fetch(:application) %> backu
35
35
  ##
36
36
  # Hipchat [Notifier]
37
37
  #
38
+ <% if fetch(:use_hipchat).casecmp('y') != 0 %>
38
39
  =begin
40
+ <% end %>
39
41
  notify_by Hipchat do |hipchat|
40
42
  hipchat.on_success = true
41
43
  hipchat.on_warning = true
42
44
  hipchat.on_failure = true
43
- hipchat.token = "change_token"
44
- hipchat.from = "<%= fetch(:application) %> Backup"
45
+ hipchat.token = "<%= fetch(:hipchat_token) %>"
46
+ # get first 15 character of application, there is an error after 15 length
47
+ hipchat.from = "<%= fetch(:application)[0..14] %>"
45
48
  hipchat.rooms_notified = ["backup"]
46
49
  hipchat.success_color = "green"
47
50
  hipchat.warning_color = "yellow"
48
51
  hipchat.failure_color = "red"
49
52
  end
53
+ <% if fetch(:use_hipchat).casecmp('y') != 0 %>
50
54
  =end
55
+ <% end %>
51
56
 
52
57
  end
@@ -3,7 +3,7 @@ namespace :db do
3
3
  task :setup do
4
4
  on roles(:app) do
5
5
  execute "mkdir -p #{fetch(:shared_path)}/config"
6
- template 'database.yml.erb', "#{shared_path}/config/database.yml"
6
+ template 'database.yml.erb', "#{fetch(:shared_path)}/config/database.yml"
7
7
  end
8
8
  end
9
9
  desc 'Run rake db:seed.'
@@ -16,4 +16,16 @@ namespace :db do
16
16
  end
17
17
  end
18
18
  end
19
+ desc 'Create empty database file'
20
+ task :create_file do
21
+ on roles(:app) do
22
+ execute :mkdir, '-p', "#{fetch(:shared_path)}/config"
23
+ if test("[ -f #{fetch(:shared_path)}/config/database.yml ]")
24
+ debug "#{fetch(:shared_path)}/config/database.yml file is exist"
25
+ else
26
+ info "#{fetch(:shared_path)}/config/database.yml file does not exist, and it has been created"
27
+ template 'database.yml.erb', "#{fetch(:shared_path)}/config/database.yml"
28
+ end
29
+ end
30
+ end
19
31
  end
@@ -3,29 +3,39 @@ namespace :postgresql do
3
3
  desc 'Setup postgresql for application'
4
4
  task :setup do
5
5
  # Ask information
6
- ask :user, "Postgresql username"
7
- ask :password, "Postgresql password for #{fetch(:user)}"
8
- ask :database, "Postgresql database"
9
-
10
- # Set variables
11
- set :postgresql_host, 'localhost'
12
- set :postgresql_port, '5432'
13
- set :postgresql_user, fetch(:user)
14
- set :postgresql_database, fetch(:database)
15
- set :postgresql_password, fetch(:password)
6
+ ask :postgresql_user, "Postgresql username"
7
+ puts fetch(:postgresql_user)
8
+ ask :postgresql_password, "Postgresql password for #{fetch(:postgresql_user)}"
9
+ puts fetch(:postgresql_password)
10
+ ask :postgresql_database, "Postgresql database"
11
+ puts fetch(:postgresql_database)
12
+ ask :create_db_user, "Create database user? Yes(y) or No(n)"
13
+ puts fetch(:create_db_user)
14
+ ask :create_db, "Create database? Yes(y) or No(n)"
15
+ puts fetch(:create_db)
16
+ ask :use_hipchat, "Do you want to add hipchat token? Yes(y) or No(n)"
17
+ puts fetch(:use_hipchat)
18
+ if fetch(:use_hipchat).casecmp('y') == 0
19
+ ask :hipchat_token, "Hipchat token"
20
+ puts fetch(:hipchat_token)
21
+ end
16
22
 
17
23
  # Run queries
18
24
  on roles(:app) do
19
- puts 'Creating user with password'
20
- # Create database user
21
- sudo %Q{sudo -u postgres psql -c "create user #{fetch(:postgresql_user)} with password '#{fetch(:postgresql_password)}';"}
22
- puts 'Creating database with owner'
23
- sudo %Q{sudo -u postgres psql -c "create database "#{fetch(:postgresql_database)}_#{fetch(:rails_env)}" owner #{fetch(:postgresql_user)} encoding 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TEMPLATE template0;"}
24
25
 
26
+ if fetch(:create_db_user).casecmp('y') == 0
27
+ puts 'Creating user with password'
28
+ # Create database user
29
+ sudo %Q{sudo -u postgres psql -c "create user #{fetch(:postgresql_user)} with password '#{fetch(:postgresql_password)}';"}
30
+ end
31
+ if fetch(:create_db).casecmp('y') == 0
32
+ puts 'Creating database with owner'
33
+ sudo %Q{sudo -u postgres psql -c "create database "#{fetch(:postgresql_database)}_#{fetch(:rails_env)}" owner #{fetch(:postgresql_user)} encoding 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TEMPLATE template0;"}
34
+ end
25
35
  puts 'Creating database.yml.'
26
36
  # Configure database settings
27
37
  execute "mkdir -p #{fetch(:shared_path)}/config"
28
- template 'database.yml.erb', "#{shared_path}/config/database.yml"
38
+ template 'database.yml.erb', "#{fetch(:shared_path)}/config/database.yml"
29
39
 
30
40
  puts 'Creating backup model.'
31
41
  # Check model is exist
@@ -50,17 +60,4 @@ namespace :postgresql do
50
60
  end
51
61
  end
52
62
 
53
- # Create database file on start
54
- task :create_database_file do
55
- on roles(:app) do
56
- execute :mkdir, '-p', "#{fetch(:shared_path)}/config"
57
- if test("[ -f #{fetch(:shared_path)}/config/database.yml ]")
58
- debug "#{fetch(:shared_path)}/config/database.yml file is exist"
59
- else
60
- info "#{fetch(:shared_path)}/config/database.yml file does not exist, and it has been created"
61
- template 'database.yml.erb', "#{shared_path}/config/database.yml"
62
- end
63
- end
64
- end
65
-
66
63
  end
@@ -0,0 +1,12 @@
1
+ namespace :rails do
2
+
3
+ desc 'Open a rails console `cap [staging] rails:console [server_index default: 0]`'
4
+ task :console do
5
+ server = roles(:app)[ARGV[2].to_i]
6
+ puts "Opening a console on: #{server.hostname}…."
7
+ cmd = "ssh #{server.user}@#{server.hostname} -tp #{server.port} 'cd #{fetch(:current_path)} && RAILS_ENV=#{fetch(:rails_env)} #{fetch(:run_path)}bundle exec rails console'"
8
+ puts cmd
9
+ exec cmd
10
+ end
11
+
12
+ end
@@ -0,0 +1,28 @@
1
+ namespace :uploads do
2
+
3
+ desc 'Upload your directory files'
4
+ task :do do
5
+ # your local file root directories
6
+ # TODO change array values
7
+ upload_dirs = ['public/your_upload', 'public/your_image' ]
8
+ # your server upload directory
9
+ upload_to_dir= "#{fetch(:shared_path)}/"
10
+
11
+ on roles(:app) do
12
+ upload_dirs.map do |d|
13
+ dir = File.expand_path(d)
14
+ files = Dir.glob("#{dir}/**/**/**/**/**/**")
15
+ files.map do |file|
16
+ name = file[file.index(d)..-1]
17
+ path = "#{upload_to_dir}#{name}"
18
+ puts "File uploading to path: #{path}"
19
+ if File.directory?(file)
20
+ execute "mkdir -p #{path}"
21
+ else
22
+ upload! file,"#{path}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module RecipesMatic
2
- VERSION = '1.2.1'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recipes_matic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lab2023
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,8 @@ files:
67
67
  - MIT-LICENSE
68
68
  - README.md
69
69
  - Rakefile
70
+ - example_Capfile
71
+ - example_deploy.rb
70
72
  - lib/generators/recipes_matic/install_generator.rb
71
73
  - lib/generators/recipes_matic/templates/config/deploy/recipes/base.rb
72
74
  - lib/generators/recipes_matic/templates/config/deploy/recipes/templates/backup_model.erb
@@ -85,7 +87,9 @@ files:
85
87
  - lib/generators/recipes_matic/templates/lib/capistrano/tasks/monit.rake
86
88
  - lib/generators/recipes_matic/templates/lib/capistrano/tasks/nginx.rake
87
89
  - lib/generators/recipes_matic/templates/lib/capistrano/tasks/postgresql.rake
90
+ - lib/generators/recipes_matic/templates/lib/capistrano/tasks/rails.rake
88
91
  - lib/generators/recipes_matic/templates/lib/capistrano/tasks/unicorn.rake
92
+ - lib/generators/recipes_matic/templates/lib/capistrano/tasks/uploads.rake
89
93
  - lib/recipes_matic.rb
90
94
  - lib/recipes_matic/version.rb
91
95
  - recipes_matic.gemspec