standup 0.5.11 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require 'tempfile'
2
+ require 'timeout'
2
3
 
3
4
  module Standup
4
5
  class Remoting
@@ -52,7 +53,8 @@ module Standup
52
53
  :sudo => opts[:sudo]
53
54
  end
54
55
 
55
- def with_context new_context = {}, replace = false
56
+ def with_context new_context, replace = false
57
+ new_context ||= {}
56
58
  old_context = @context.dup
57
59
  @context = replace ? new_context : @context.merge(new_context).merge(:prefix => "#{old_context[:prefix]} #{new_context[:prefix]}")
58
60
  yield(@context).tap { @context = old_context }
@@ -73,7 +75,7 @@ module Standup
73
75
  with_context(:prefix => prefix, &block)
74
76
  end
75
77
 
76
- def raw_exec command
78
+ def raw_exec command, timeout_sec = nil
77
79
  bright_p command
78
80
 
79
81
  result = ''
@@ -98,7 +100,16 @@ module Standup
98
100
  end
99
101
  end
100
102
 
101
- main_channel.wait
103
+ if timeout_sec
104
+ begin
105
+ timeout(timeout_sec) { main_channel.wait }
106
+ rescue Timeout::Error
107
+ puts "Timeout of #{timeout_sec} happens, connection is closing."
108
+ end
109
+ else
110
+ main_channel.wait
111
+ end
112
+
102
113
  main_channel.close
103
114
 
104
115
  result
@@ -118,8 +129,8 @@ module Standup
118
129
  command
119
130
  end
120
131
 
121
- def exec command, context = {}
122
- with_context(context) { raw_exec(remote_command(command)) }
132
+ def exec command, context = nil, timeout_sec = nil
133
+ with_context(context) { raw_exec(remote_command(command), timeout_sec) }
123
134
  end
124
135
 
125
136
  def shell_command
@@ -185,7 +196,7 @@ module Standup
185
196
  end
186
197
 
187
198
  def close
188
- @ssh.close if @ssh
199
+ @ssh.shutdown! if @ssh
189
200
  @ssh = nil
190
201
  end
191
202
 
@@ -1,5 +1,5 @@
1
1
  module Standup
2
- VERSION = "0.5.11"
2
+ VERSION = "0.5.13"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -19,7 +19,6 @@ webapp:
19
19
  name:
20
20
  github_user:
21
21
  github_repo:
22
- bootstrap_db: true
23
22
 
24
23
  # Nodes and their script params
25
24
  nodes:
@@ -0,0 +1,49 @@
1
+ <%
2
+ common_props = <<-END
3
+ daily
4
+ rotate 30
5
+
6
+ missingok
7
+ notifempty
8
+
9
+ compress
10
+ delaycompress
11
+ END
12
+ %>
13
+
14
+ <% if scripts.setup.has_script? 'passenger' %>
15
+ /opt/nginx/logs/*.log {
16
+ <%= common_props %>
17
+ sharedscripts
18
+
19
+ postrotate
20
+ test ! -f /var/run/nginx.pid || kill -USR1 'cat /var/run/nginx.pid'
21
+ endscript
22
+ }
23
+ <% end %>
24
+
25
+ <% if scripts.setup.has_script? 'webapp' %>
26
+
27
+ <%= scripts.webapp.app_path %>log/<%= scripts.webapp.params.rails_env %>.log {
28
+ <%= common_props %>
29
+ postrotate
30
+ touch <%= scripts.webapp.app_path %>tmp/restart.txt
31
+ endscript
32
+ }
33
+
34
+ <% end %>
35
+
36
+ <% if scripts.setup.has_script?('resque') && scripts.webapp.params.has_key?(:resque_queues) %>
37
+ <% scripts.webapp.params.resque_queues.each_pair do |resque_name, num_of_workers| %>
38
+ <% 1.upto(num_of_workers) do |num| %>
39
+
40
+ <%= scripts.webapp.app_path %>log/<%= "resque_worker_#{resque_name}_#{num}" %>.log {
41
+ <%= common_props %>
42
+ postrotate
43
+ /usr/sbin/monit restart <%= "resque_#{resque_name}_#{num}" %>
44
+ endscript
45
+ }
46
+
47
+ <% end %>
48
+ <% end %>
49
+ <% end %>
@@ -0,0 +1,9 @@
1
+ Standup.script :node do
2
+ def run
3
+ with_processed_file script_file('logrotate.conf.erb') do |file|
4
+ upload file,
5
+ :to => "/etc/logrotate.d/standup",
6
+ :sudo => true
7
+ end
8
+ end
9
+ end
@@ -35,11 +35,11 @@ Standup.script :node do
35
35
  end
36
36
 
37
37
  def create_database name, local = false
38
- if exec_sql("select * from pg_database where datname = '#{name}'", local) =~ /1 row/
39
- false
40
- else
38
+ if exec_sql("select * from pg_database where datname = '#{name}'", local) =~ /\(0 rows\)/
41
39
  exec_sql "create database #{name}", local
42
40
  true
41
+ else
42
+ false
43
43
  end
44
44
  end
45
45
 
@@ -0,0 +1 @@
1
+ export rvm_path=/usr/local/rvm
data/scripts/ruby.rb CHANGED
@@ -6,6 +6,7 @@ Standup.script :node do
6
6
  sudo 'usermod -a -G rvm ubuntu'
7
7
  sudo 'usermod -a -G rvm www-data'
8
8
  sudo 'cd /usr/local/bin && sudo ln -s /usr/local/rvm/bin/rvm-shell'
9
+ upload script_file('rvmrc'), :to => '/etc/rvmrc', :sudo => true
9
10
  exec 'source /usr/local/rvm/scripts/rvm'
10
11
  remoting.instance_variable_set :@rvm_installed, true
11
12
  end
data/scripts/webapp.rb CHANGED
@@ -5,7 +5,6 @@ Standup.script :node do
5
5
  :server_name => '_',
6
6
  :git_branch => 'master',
7
7
  :gem_manager => :bundler,
8
- :bootstrap_db => false,
9
8
  :app_subdir => ''
10
9
  }
11
10
 
@@ -37,7 +36,7 @@ Standup.script :node do
37
36
 
38
37
  install_gems
39
38
 
40
- bootstrap_db if params.bootstrap_db
39
+ bootstrap_db
41
40
 
42
41
  #TODO replace rvm ruby with wrapper!!!
43
42
  with_processed_file script_file('webapp.conf') do |file|
@@ -116,7 +115,7 @@ Standup.script :node do
116
115
  exec "ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' -C `hostname`"
117
116
  end
118
117
 
119
- while exec('ssh -o StrictHostKeyChecking=no git@github.com') =~ /Permission denied \(publickey\)/
118
+ while exec('ssh -o StrictHostKeyChecking=no git@github.com', nil, 10) =~ /Permission denied \(publickey\)/
120
119
  password = bright_ask("Enter GitGub password for user #{params.github_user}:", false)
121
120
 
122
121
  github_add_deploy_key params.github_user,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.5.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-08-22 00:00:00.000000000Z
14
+ date: 2011-09-09 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: trollop
18
- requirement: &70335336567100 !ruby/object:Gem::Requirement
18
+ requirement: &70198872104340 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '1.16'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70335336567100
26
+ version_requirements: *70198872104340
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
- requirement: &70335336563600 !ruby/object:Gem::Requirement
29
+ requirement: &70198872103840 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.5.0
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70335336563600
37
+ version_requirements: *70198872103840
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: activesupport
40
- requirement: &70335336559920 !ruby/object:Gem::Requirement
40
+ requirement: &70198872103380 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '3.0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *70335336559920
48
+ version_requirements: *70198872103380
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: settingslogic
51
- requirement: &70335336580740 !ruby/object:Gem::Requirement
51
+ requirement: &70198872102920 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '2.0'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *70335336580740
59
+ version_requirements: *70198872102920
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: amazon-ec2
62
- requirement: &70335336617660 !ruby/object:Gem::Requirement
62
+ requirement: &70198872102460 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0.9'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *70335336617660
70
+ version_requirements: *70198872102460
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: aws-s3
73
- requirement: &70335336628020 !ruby/object:Gem::Requirement
73
+ requirement: &70198872102000 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0.5'
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *70335336628020
81
+ version_requirements: *70198872102000
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: net-ssh
84
- requirement: &70335336634060 !ruby/object:Gem::Requirement
84
+ requirement: &70198872101540 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '2.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
- version_requirements: *70335336634060
92
+ version_requirements: *70198872101540
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: highline
95
- requirement: &70335336638160 !ruby/object:Gem::Requirement
95
+ requirement: &70198872101080 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,7 +100,7 @@ dependencies:
100
100
  version: 1.5.2
101
101
  type: :runtime
102
102
  prerelease: false
103
- version_requirements: *70335336638160
103
+ version_requirements: *70198872101080
104
104
  description: ''
105
105
  email:
106
106
  - ilia@flamefork.ru
@@ -147,6 +147,8 @@ files:
147
147
  - scripts/init.rb
148
148
  - scripts/init/standup.yml
149
149
  - scripts/localize.rb
150
+ - scripts/logrotate.rb
151
+ - scripts/logrotate/logrotate.conf.erb
150
152
  - scripts/monit.rb
151
153
  - scripts/monit/monit
152
154
  - scripts/monit/monitrc
@@ -170,6 +172,7 @@ files:
170
172
  - scripts/resque/resque_monit.conf
171
173
  - scripts/ruby.rb
172
174
  - scripts/ruby/gemrc
175
+ - scripts/ruby/rvmrc
173
176
  - scripts/setup.rb
174
177
  - scripts/shell.rb
175
178
  - scripts/status.rb
@@ -195,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
198
  version: '0'
196
199
  segments:
197
200
  - 0
198
- hash: -3527928499941133534
201
+ hash: 2756298026055865495
199
202
  required_rubygems_version: !ruby/object:Gem::Requirement
200
203
  none: false
201
204
  requirements:
@@ -204,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
207
  version: '0'
205
208
  segments:
206
209
  - 0
207
- hash: -3527928499941133534
210
+ hash: 2756298026055865495
208
211
  requirements: []
209
212
  rubyforge_project: standup
210
213
  rubygems_version: 1.8.6