capobvious 0.2.7 → 0.2.8

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.
@@ -16,7 +16,6 @@ Capistrano::Configuration.instance.load do
16
16
  set :use_sudo, false unless exists?(:use_sudo)
17
17
  set :scm, :git unless exists?(:scm)
18
18
 
19
-
20
19
  set :unicorn_init, "unicorn_#{application}"
21
20
  set :unicorn_conf, "#{current_path}/config/unicorn.rb"
22
21
  set :unicorn_pid, "#{shared_path}/pids/unicorn.pid"
@@ -24,26 +23,20 @@ Capistrano::Configuration.instance.load do
24
23
  psql = "psql -h localhost"
25
24
  psql_postgres = "#{psql} -U postgres"
26
25
 
27
- # psql_postgre = if `uname -a`.include?("Darwin")
28
- # else
29
- # "#{sudo} -u postgres psql"
30
- # end
31
-
32
26
  database_yml_path = "config/database.yml"
33
27
 
34
28
  serv_path = "#{current_path}/#{database_yml_path}"
35
- if capture("if [ -f #{serv_path} ]; then echo '1'; fi") == '1'
36
- database_yml = capture("cat #{serv_path}")
37
- else
38
- database_yml = File.open(database_yml_path)
39
- end
29
+ #if capture("if [ -f #{serv_path} ]; then echo '1'; fi") == '1'
30
+ # database_yml = capture("cat #{serv_path}")
31
+ #else
32
+ database_yml = File.open(database_yml_path)
33
+ #end
40
34
  config = YAML::load(database_yml)
41
35
  adapter = config[rails_env]["adapter"]
42
36
  database = config[rails_env]["database"]
43
37
  db_username = config[rails_env]["username"]
44
38
  db_password = config[rails_env]["password"]
45
39
 
46
-
47
40
  config = YAML::load(File.open(database_yml_path))
48
41
  local_rails_env = 'development'
49
42
  local_adapter = config[local_rails_env]["adapter"]
@@ -51,8 +44,6 @@ Capistrano::Configuration.instance.load do
51
44
  local_db_username = config[local_rails_env]["username"]||`whoami`.chop
52
45
  local_db_password = config[local_rails_env]["password"]
53
46
 
54
-
55
-
56
47
  set :local_folder_path, "tmp/backup"
57
48
  set :timestamp, Time.new.to_i.to_s
58
49
  set :db_archive_ext, "tar.bz2"
@@ -63,27 +54,27 @@ Capistrano::Configuration.instance.load do
63
54
  set :sys_file_name, "#{application}-system-#{timestamp}.#{db_archive_ext}"
64
55
  set :del_backup, true
65
56
 
66
-
67
57
  def gem_use?(name)
68
58
  gemfile_lock = File.read("Gemfile.lock")
69
- return (gemfile_lock =~ /^\s*delayed_job\s+\(/)? true : false
59
+ return (gemfile_lock =~ /^\s*#{name}\s+\(/)? true : false
70
60
  end
71
61
 
72
- if gem_use?('delayed_job')
73
- unless exists?(:delayed_job)
74
- logger.important("delayed_job set to true")
75
- set :delayed_job, true
62
+ VarGems = {'delayed_job' => :delayed_job, 'activerecord-postgres-hstore' => :hstore}
63
+
64
+ VarGems.each do |gem,var|
65
+ gem = gem.to_s
66
+ var = var.to_sym
67
+ if gem_use?(gem)
68
+ unless exists?(var)
69
+ logger.debug "gem '#{gem}' is found"
70
+ logger.important("#{var} set to true")
71
+ set var, true
72
+ end
76
73
  end
77
74
  end
78
75
 
79
- #after "deploy:symlink", "auto:run"
80
- #after "deploy:setup", "db:create", "nginx:conf", "install:p7zip"
81
-
82
- # load 'deploy/assets'
83
-
84
76
  after 'deploy:update_code', 'bundle:install'
85
77
  after "deploy:update", "deploy:cleanup"
86
-
87
78
 
88
79
  if !exists?(:assets) || fetch(:assets) == true
89
80
  after 'deploy:update_code', 'assets:precompile'
@@ -657,4 +648,36 @@ EOF
657
648
  size = run("wc -c #{file_path} | cut -d' ' -f1")
658
649
  return size
659
650
  end
651
+
652
+ after 'deploy:setup', 'logrotate:init'
653
+
654
+ set :logrotate_path, '/etc/logrotate.d'
655
+ set :logrotate_file_name, "cap_#{application}"
656
+ set :logrotate_file, "#{logrotate_path}/#{logrotate_file_name}"
657
+ namespace :logrotate do
658
+ #http://stackoverflow.com/questions/4883891/ruby-on-rails-production-log-rotation
659
+ task :init do
660
+ str = %|
661
+ #{shared_path}/log/*.log {
662
+ weekly
663
+ missingok
664
+ rotate 52
665
+ compress
666
+ delaycompress
667
+ notifempty
668
+ create 640 root adm
669
+ sharedscripts
670
+ endscript
671
+ copytruncate
672
+ }
673
+ |
674
+ temp_path = "/tmp/#{logrotate_file_name}"
675
+ put str, temp_path
676
+ run "#{sudo} mv -v #{temp_path} #{logrotate_file}"
677
+ end
678
+ task :stop do
679
+ run "#{sudo} rm #{logrotate_file}"
680
+ end
681
+ end
682
+
660
683
  end
@@ -1,3 +1,3 @@
1
1
  module Capobvious
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capobvious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: