oysters 0.0.4 → 0.9.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5d3939566273ee19cbdaefe37521518a9655b5f
4
- data.tar.gz: 1a4aeb3ef58de3d219a85f918f6dd242eabb97a3
3
+ metadata.gz: d3548f9d183107ebe52ddfa88605ae91fbc19dd0
4
+ data.tar.gz: 25aa27865a220441f0a4f9bf2dec90a6b04fd9b5
5
5
  SHA512:
6
- metadata.gz: b65b514601c3dcf92981b880dc973dadcc8ceeb250644801e313d61be70519943b4c4c6b192a1545ba9aa54940adc04e3a2f8c4ceeab1eaf6db0750906878721
7
- data.tar.gz: 6474e3392b8f17735af068bb8ed6b953ace3a4e4ae0bb6ae8736ebdd907ed98deb63d8189f763befe9d5671cfcd5bac26d8ae787b4b6643a30e977dc896858eb
6
+ metadata.gz: abe8efdb87b84586452b3bdd3cb608702da9b8c46f5b4e0311e77bb6ac43b92947ad5ab8ee4d61994aa0e5c6abe757cfe3ab79f166b48d87ad2f05165fa8dc8b
7
+ data.tar.gz: 5eb356b4c80ae2976d91c480804e8ba9e112f31eefd141c9c8c907e7e66baf12057f0687afb72a80e099b27d09dd5a4e378d2ed2eb8c63800d6ec64725661f4d
@@ -0,0 +1,32 @@
1
+ require 'oysters'
2
+
3
+ Oysters.with_configuration do
4
+ namespace :initd do
5
+
6
+ INITD_SERVICES = %w(nginx memcached redis unicorn thin god mysql postgres)
7
+ set :initd_services, INITD_SERVICES unless exists?(:initd_services)
8
+
9
+ desc "Check if all needed services are enabled to run on system start-up"
10
+ task :check do
11
+ services_str = initd_services.join('|')
12
+ results = capture("/sbin/chkconfig --list | egrep '#{services_str}'").split("\n")
13
+
14
+ results.each do |result|
15
+ service_name = result.match(/\S+/)[0]
16
+
17
+ print "Checking #{service_name}... "
18
+ if result =~ /3:on/ && result =~ /4:on/ && result =~ /5:on/
19
+ puts 'OK'
20
+ else
21
+ puts 'Failed! Fixing...'
22
+ sudo "/sbin/chkconfig --level 345 #{service_name} on"
23
+ end
24
+
25
+ puts "\n"
26
+ end
27
+
28
+ puts 'Done!'
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ require 'oysters'
2
+ require 'erb'
3
+
4
+ Oysters.with_configuration do
5
+ namespace :initd do
6
+
7
+ namespace :kewatcher do
8
+ desc 'Generate kewatcher init.d script'
9
+ task :setup, roles: :app do
10
+ run "mkdir -p #{shared_path}/config"
11
+ location = File.expand_path('../../templates/kewatcher_init.sh.erb', __FILE__)
12
+ config = ERB.new(File.read(location))
13
+ put config.result(binding), "#{shared_path}/config/#{application}_kewatcher_init.sh"
14
+ end
15
+
16
+ desc 'Copy kewatcher into an init.d and adds to chkconfig'
17
+ task :install, roles: :app do
18
+ sudo "cp #{shared_path}/config/#{application}_kewatcher_init.sh /etc/init.d/#{application}_kewatcher;\
19
+ sudo chmod +x /etc/init.d/#{application}_kewatcher;\
20
+ sudo chkconfig --add #{application}_kewatcher", pty: true
21
+ end
22
+
23
+ desc 'Removes kewatcher from an init.d and deletes from chkconfig'
24
+ task :uninstall, roles: :app do
25
+ sudo "chkconfig --del #{application}_kewatcher;\
26
+ sudo rm -f /etc/init.d/#{application}_kewatcher", pty: true
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require 'oysters'
2
+ require 'erb'
3
+
4
+ Oysters.with_configuration do
5
+ namespace :initd do
6
+
7
+ namespace :logrotate do
8
+ desc 'Install logrotate config'
9
+ task :install, roles: :app do
10
+ log_path = Pathname.new(shared_path).join('log', "#{rails_env}.log").to_s
11
+ tmp_file = "/tmp/#{application}_logs_#{rand}"
12
+ location = File.expand_path('../../templates/logrotate_config.erb', __FILE__)
13
+ config = ERB.new(File.read(location))
14
+
15
+ put config.result(binding), tmp_file
16
+ sudo "mv #{tmp_file} /etc/logrotate.d/#{application}_logs"
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ require 'oysters'
2
+
3
+ Oysters.with_configuration do
4
+ namespace :initd do
5
+
6
+ set :ntp_host, 'pool.ntp.org' unless exists?(:ntp_host)
7
+
8
+ namespace :ntp do
9
+ desc 'Installs and configures ntp service'
10
+ task :install do
11
+ sudo "yum install -y ntp;\
12
+ sudo chkconfig ntpd on;\
13
+ sudo service ntpd stop;\
14
+ sleep 3;\
15
+ if [[ ! `grep 'server #{ntp_host}' /etc/ntp.conf` ]];
16
+ then
17
+ sudo sed -i '0,/^server /s//server #{ntp_host}\n&/' /etc/ntp.conf;\
18
+ fi;\
19
+ if [[ ! `grep '#{ntp_host}' /etc/ntp/step-tickers` ]];
20
+ then
21
+ sudo sed -i '0,/^#.*$/s//&\n#{ntp_host}/' /etc/ntp/step-tickers;\
22
+ fi;\
23
+ sudo ntpdate #{ntp_host};\
24
+ sleep 1;\
25
+ sudo service ntpd start;
26
+ "
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,38 @@
1
+ require 'oysters'
2
+ require 'erb'
3
+
4
+ Oysters.with_configuration do
5
+ namespace :initd do
6
+
7
+ namespace :unicorn do
8
+ desc 'Generate unicorn init.d script'
9
+ task :setup, roles: :app do
10
+ su_command = "su - #{user} -c"
11
+ CapistranoUnicorn::Config.load self
12
+ CapistranoUnicorn::Utility.send(:alias_method, :old_try_unicorn_user, :try_unicorn_user)
13
+ CapistranoUnicorn::Utility.send(:define_method, :try_unicorn_user, Proc.new { su_command })
14
+ run "mkdir -p #{shared_path}/config"
15
+ location = File.expand_path('../../templates/unicorn_init.sh.erb', __FILE__)
16
+ config = ERB.new(File.read(location))
17
+ text_config = config.result(binding)
18
+ text_config.gsub!(/(#{su_command}) (.*);/,'\1 "\2";')
19
+ put text_config, "#{shared_path}/config/#{application}_unicorn_init.sh"
20
+ CapistranoUnicorn::Utility.send(:alias_method, :try_unicorn_user, :old_try_unicorn_user)
21
+ end
22
+
23
+ desc 'Copy unicorn into an init.d and add to chkconfig'
24
+ task :install, roles: :app do
25
+ sudo "cp #{shared_path}/config/#{application}_unicorn_init.sh /etc/init.d/#{application}_unicorn_#{rails_env};\
26
+ sudo chmod +x /etc/init.d/#{application}_unicorn_#{rails_env};\
27
+ sudo chkconfig --add #{application}_unicorn_#{rails_env}", pty: true
28
+ end
29
+
30
+ desc 'Removes unicorn from an init.d and deletes from chkconfig'
31
+ task :uninstall, roles: :app do
32
+ sudo "chkconfig --del #{application}_unicorn_#{rails_env};\
33
+ sudo rm -f /etc/init.d/#{application}_unicorn_#{rails_env}", pty: true
34
+ end
35
+ end
36
+
37
+ end
38
+ end
data/lib/oysters/initd.rb CHANGED
@@ -1,124 +1,5 @@
1
1
  require 'oysters'
2
- require 'erb'
3
-
4
- Oysters.with_configuration do
5
-
6
- namespace :initd do
7
-
8
- namespace :unicorn do
9
- desc 'Generate unicorn init.d script'
10
- task :setup, roles: :app do
11
- su_command = "su - #{user} -c"
12
- CapistranoUnicorn::Config.load self
13
- CapistranoUnicorn::Utility.send(:alias_method, :old_try_unicorn_user, :try_unicorn_user)
14
- CapistranoUnicorn::Utility.send(:define_method, :try_unicorn_user, Proc.new { su_command })
15
- run "mkdir -p #{shared_path}/config"
16
- location = File.expand_path('../templates/unicorn_init.sh.erb', __FILE__)
17
- config = ERB.new(File.read(location))
18
- text_config = config.result(binding)
19
- text_config.gsub!(/(#{su_command}) (.*);/,'\1 "\2";')
20
- put text_config, "#{shared_path}/config/#{application}_unicorn_init.sh"
21
- CapistranoUnicorn::Utility.send(:alias_method, :try_unicorn_user, :old_try_unicorn_user)
22
- end
23
-
24
- desc 'Copy unicorn into an init.d and add to chkconfig'
25
- task :install, roles: :app do
26
- sudo "cp #{shared_path}/config/#{application}_unicorn_init.sh /etc/init.d/#{application}_unicorn_#{rails_env};\
27
- sudo chmod +x /etc/init.d/#{application}_unicorn_#{rails_env};\
28
- sudo chkconfig --add #{application}_unicorn_#{rails_env}", pty: true
29
- end
30
-
31
- desc 'Removes unicorn from an init.d and deletes from chkconfig'
32
- task :uninstall, roles: :app do
33
- sudo "chkconfig --del #{application}_unicorn_#{rails_env};\
34
- sudo rm -f /etc/init.d/#{application}_unicorn_#{rails_env}", pty: true
35
- end
36
- end
37
-
38
- set :ntp_host, 'pool.ntp.org' unless exists?(:ntp_host)
39
-
40
- namespace :ntp do
41
- desc 'Installs and configures ntp service'
42
- task :install do
43
- sudo "yum install -y ntp;\
44
- sudo chkconfig ntpd on;\
45
- sudo service ntpd stop;\
46
- sleep 3;\
47
- if [[ ! `grep 'server #{ntp_host}' /etc/ntp.conf` ]];
48
- then
49
- sudo sed -i '0,/^server /s//server #{ntp_host}\n&/' /etc/ntp.conf;\
50
- fi;\
51
- if [[ ! `grep '#{ntp_host}' /etc/ntp/step-tickers` ]];
52
- then
53
- sudo sed -i '0,/^#.*$/s//&\n#{ntp_host}/' /etc/ntp/step-tickers;\
54
- fi;\
55
- sudo ntpdate #{ntp_host};\
56
- sleep 1;\
57
- sudo service ntpd start;
58
- "
59
- end
60
- end
61
-
62
- INITD_SERVICES = %w(nginx memcached redis unicorn thin god mysql postgres)
63
- set :initd_services, INITD_SERVICES unless exists?(:initd_services)
64
-
65
- desc "Check if all needed services are enabled to run on system start-up"
66
- task :check do
67
- services_str = initd_services.join('|')
68
- results = capture("/sbin/chkconfig --list | egrep '#{services_str}'").split("\n")
69
-
70
- results.each do |result|
71
- service_name = result.match(/\S+/)[0]
72
-
73
- print "Checking #{service_name}... "
74
- if result =~ /3:on/ && result =~ /4:on/ && result =~ /5:on/
75
- puts 'OK'
76
- else
77
- puts 'Failed! Fixing...'
78
- sudo "/sbin/chkconfig --level 345 #{service_name} on"
79
- end
80
-
81
- puts "\n"
82
- end
83
-
84
- puts 'Done!'
85
- end
86
-
87
- namespace :kewatcher do
88
- desc 'Generate kewatcher init.d script'
89
- task :setup, roles: :app do
90
- run "mkdir -p #{shared_path}/config"
91
- location = File.expand_path('../templates/kewatcher_init.sh.erb', __FILE__)
92
- config = ERB.new(File.read(location))
93
- put config.result(binding), "#{shared_path}/config/#{application}_kewatcher_init.sh"
94
- end
95
-
96
- desc 'Copy kewatcher into an init.d and adds to chkconfig'
97
- task :install, roles: :app do
98
- sudo "cp #{shared_path}/config/#{application}_kewatcher_init.sh /etc/init.d/#{application}_kewatcher;\
99
- sudo chmod +x /etc/init.d/#{application}_kewatcher;\
100
- sudo chkconfig --add #{application}_kewatcher", pty: true
101
- end
102
-
103
- desc 'Removes kewatcher from an init.d and deletes from chkconfig'
104
- task :uninstall, roles: :app do
105
- sudo "chkconfig --del #{application}_kewatcher;\
106
- sudo rm -f /etc/init.d/#{application}_kewatcher", pty: true
107
- end
108
- end
109
-
110
- namespace :logrotate do
111
- desc 'Install logrotate config'
112
- task :install, roles: :app do
113
- log_path = Pathname.new(shared_path).join('log', "#{rails_env}.log").to_s
114
- tmp_file = "/tmp/#{application}_logs_#{rand}"
115
- location = File.expand_path('../templates/logrotate_config.erb', __FILE__)
116
- config = ERB.new(File.read(location))
117
-
118
- put config.result(binding), tmp_file
119
- sudo "mv #{tmp_file} /etc/logrotate.d/#{application}_logs"
120
- end
121
- end
122
- end
123
2
 
3
+ Dir[File.dirname(__FILE__) + '/initd/*.rb'].each do |f|
4
+ require f
124
5
  end
@@ -1,3 +1,3 @@
1
1
  module Oysters
2
- VERSION = "0.0.4"
2
+ VERSION = "0.9.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oysters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Samoilov
@@ -69,6 +69,11 @@ files:
69
69
  - lib/oysters.rb
70
70
  - lib/oysters/dalli.rb
71
71
  - lib/oysters/initd.rb
72
+ - lib/oysters/initd/check.rb
73
+ - lib/oysters/initd/kewatcher.rb
74
+ - lib/oysters/initd/logrotate.rb
75
+ - lib/oysters/initd/ntp.rb
76
+ - lib/oysters/initd/unicorn.rb
72
77
  - lib/oysters/resque_scheduler.rb
73
78
  - lib/oysters/resque_sliders.rb
74
79
  - lib/oysters/templates/kewatcher_init.sh.erb