standup 0.3.15 → 0.3.16

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.authors = ['Ilia Ablamonov', 'Artem Orlov', 'Cloud Castle Inc.']
12
12
 
13
13
  gem.add_dependency 'trollop', '>= 1.16'
14
+ gem.add_dependency 'i18n', '>= 0.5.0'
14
15
  gem.add_dependency 'activesupport', '>= 3.0'
15
16
  gem.add_dependency 'settingslogic', '>= 2.0'
16
17
  gem.add_dependency 'amazon-ec2', '>= 0.9'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.15
1
+ 0.3.16
data/lib/standup/node.rb CHANGED
@@ -26,7 +26,7 @@ module Standup
26
26
 
27
27
  def ssh_string
28
28
  return '' unless instance
29
- "ssh -i #{Settings.aws.keypair_file} -q -o StrictHostKeyChecking=no #{scripts.ec2.params.ssh_user}@#{instance.external_ip}"
29
+ "ssh -i #{Settings.aws.keypair_file} -C -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{scripts.ec2.params.ssh_user}@#{instance.external_ip}"
30
30
  end
31
31
 
32
32
  def params
@@ -77,7 +77,7 @@ module Standup
77
77
  end
78
78
 
79
79
  def su_exec user, command
80
- sudo "-u #{user} \"#{command.gsub /"/, '\"'}\""
80
+ sudo "-u #{user} #{command}"
81
81
  end
82
82
 
83
83
  def in_temp_dir &block
@@ -144,7 +144,7 @@ module Standup
144
144
  def rsync source, destination, sudo
145
145
  command = [
146
146
  'rsync -rlptDzP --delete',
147
- "-e 'ssh -i #{@keypair_file} -q -o StrictHostKeyChecking=no'",
147
+ "-e 'ssh -i #{@keypair_file} -C -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'",
148
148
  ("--rsync-path='sudo rsync'" if sudo),
149
149
  [*source].join(' '),
150
150
  destination
@@ -67,8 +67,10 @@ module Standup
67
67
  script_description = description
68
68
  script_name = name
69
69
  opt_parser = Trollop::Parser.new do
70
- banner script_description
71
- banner ''
70
+ if script_description
71
+ banner script_description
72
+ banner ''
73
+ end
72
74
  banner 'Usage:'
73
75
  banner " standup #{script_name} [options] #{arg_pattern}"
74
76
  banner ''
data/lib/standup.rb CHANGED
@@ -44,7 +44,7 @@ module Standup
44
44
  end
45
45
 
46
46
  def self.script type = :node, &block
47
- name = block.__file__.match(/([^\/]*)\.rb$/)[1]
47
+ name = eval("__FILE__", block.binding).match(/([^\/]*)\.rb$/)[1]
48
48
  superclass = scripts[name] || case type
49
49
  when :node
50
50
  Scripts::Node
@@ -2,6 +2,6 @@ Standup.script :node do
2
2
  self.description = 'Run remote Rails application console'
3
3
 
4
4
  def run
5
- scripts.shell.make_shell "cd #{scripts.webapp.app_path} && rails console #{scripts.webapp.params.rails_env}"
5
+ scripts.shell.make_shell "cd #{scripts.webapp.app_path} && sudo -u www-data rails console #{scripts.webapp.params.rails_env}"
6
6
  end
7
7
  end
data/scripts/basics.rb CHANGED
@@ -10,5 +10,6 @@ Standup.script :node do
10
10
 
11
11
  sudo 'touch /var/log/cron.log'
12
12
  sudo 'chmod 666 /var/log/cron.log'
13
+ #TODO: add setting localtime zone for server
13
14
  end
14
15
  end
data/scripts/mysql.rb CHANGED
@@ -29,7 +29,6 @@ Standup.script :node do
29
29
  end
30
30
 
31
31
  def load_command database, username = 'root', password = 'root'
32
- username = 'root' if username == :local
33
32
  "mysql -u#{username} -p#{password} #{database}"
34
33
  end
35
34
  end
data/scripts/shell.rb CHANGED
@@ -16,6 +16,6 @@ Standup.script :node do
16
16
 
17
17
  def ssh_string
18
18
  return '' unless instance
19
- "ssh -i #{Standup::Settings.aws.keypair_file} #{params.extra_options} #{scripts.ec2.params.ssh_user}@#{instance.external_ip}"
19
+ "ssh -i #{Standup::Settings.aws.keypair_file} -C -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{params.extra_options} #{scripts.ec2.params.ssh_user}@#{instance.external_ip}"
20
20
  end
21
21
  end
data/scripts/update.rb CHANGED
@@ -4,13 +4,32 @@ Standup.script :node do
4
4
  def run
5
5
  in_dir scripts.webapp.app_path do
6
6
  sudo 'chown -R ubuntu:ubuntu .'
7
- exec 'git pull'
8
- sudo 'bundle install'
9
- sudo "RAILS_ENV=#{scripts.webapp.params.rails_env} rake db:migrate"
10
- sudo 'mkdir -p tmp'
7
+
8
+ pull_changes
9
+
10
+ update_webapp
11
+
11
12
  sudo 'chown -R www-data:www-data .'
12
- sudo 'touch tmp/restart.txt'
13
- scripts.delayed_job.restart if scripts.setup.has_script? 'delayed_job'
13
+
14
+ restart_webapp
14
15
  end
15
16
  end
17
+
18
+ protected
19
+
20
+ def pull_changes
21
+ exec 'git pull'
22
+ exec "git checkout #{scripts.webapp.params.git_branch}"
23
+ end
24
+
25
+ def update_webapp
26
+ scripts.webapp.install_gems
27
+ sudo "RAILS_ENV=#{scripts.webapp.params.rails_env} rake db:migrate"
28
+ end
29
+
30
+ def restart_webapp
31
+ sudo 'mkdir -p tmp'
32
+ sudo 'touch tmp/restart.txt'
33
+ scripts.delayed_job.restart if scripts.setup.has_script? 'delayed_job'
34
+ end
16
35
  end
data/scripts/webapp.rb CHANGED
@@ -2,30 +2,37 @@ Standup.script :node do
2
2
  self.default_params = {
3
3
  :rails_env => 'production',
4
4
  :name => 'webapp',
5
- :server_name => '_'
5
+ :server_name => '_',
6
+ :git_branch => 'master',
7
+ :gem_manager => :bundler
6
8
  }
7
9
 
8
10
  def run
9
11
  install_package 'git-core'
10
- install_gem 'bundler'
11
12
  install_package params.additional_packages if params.additional_packages.present?
12
13
 
13
- unless file_exists? scripts.webapp.app_path
14
- sudo "mkdir -p #{scripts.webapp.app_path}"
14
+ unless file_exists? app_path
15
+ sudo "mkdir -p #{app_path}"
15
16
  end
16
17
 
17
- sudo "chown -R ubuntu:ubuntu #{scripts.webapp.app_path}"
18
+ sudo "chown -R ubuntu:ubuntu #{app_path}"
18
19
 
19
20
  ensure_github_access
20
21
 
21
- unless file_exists? "#{scripts.webapp.app_path}/.git"
22
- exec "rm -rf #{scripts.webapp.app_path}/*"
23
- exec "git clone git@github.com:#{github_repo}.git #{scripts.webapp.app_path}"
22
+ unless file_exists? "#{app_path}/.git"
23
+ exec "rm -rf #{app_path}/*"
24
+ exec "git clone git@github.com:#{github_repo}.git #{app_path}"
24
25
  end
26
+
27
+ in_dir app_path do
28
+ exec "git checkout #{params.git_branch}"
29
+ end
30
+
31
+ install_gems
25
32
 
26
33
  bootstrap_db
27
34
 
28
- sudo "chown -R www-data:www-data #{scripts.webapp.app_path}"
35
+ sudo "chown -R www-data:www-data #{app_path}"
29
36
 
30
37
  with_processed_file script_file('webapp.conf') do |file|
31
38
  scripts.passenger.add_server_conf file, "#{params.name}.conf"
@@ -53,6 +60,18 @@ Standup.script :node do
53
60
  def server_name
54
61
  server_names.split(' ').first
55
62
  end
63
+
64
+ def install_gems
65
+ in_dir app_path do
66
+ case params.gem_manager.to_sym
67
+ when :bundler
68
+ install_gem 'bundler'
69
+ exec 'bundle install'
70
+ when :rake_gems
71
+ exec "RAILS_ENV=#{params.rails_env} rake gems:install"
72
+ end
73
+ end
74
+ end
56
75
 
57
76
  protected
58
77
 
@@ -74,8 +93,7 @@ Standup.script :node do
74
93
 
75
94
  def bootstrap_db
76
95
  if db.create_database db_name
77
- in_dir scripts.webapp.app_path do
78
- sudo 'bundle install'
96
+ in_dir app_path do
79
97
  exec "RAILS_ENV=#{params.rails_env} rake db:schema:load"
80
98
  exec "RAILS_ENV=#{params.rails_env} rake db:seed"
81
99
  end
data/standup.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{standup}
8
- s.version = "0.3.15"
8
+ s.version = "0.3.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ilia Ablamonov", "Artem Orlov", "Cloud Castle Inc."]
12
- s.date = %q{2011-01-02}
12
+ s.date = %q{2011-01-14}
13
13
  s.default_executable = %q{standup}
14
14
  s.email = %q{ilia@flamefork.ru}
15
15
  s.executables = ["standup"]
@@ -78,15 +78,15 @@ Gem::Specification.new do |s|
78
78
  ]
79
79
  s.homepage = %q{https://github.com/cloudcastle/standup}
80
80
  s.require_paths = ["lib"]
81
- s.rubygems_version = %q{1.3.7}
81
+ s.rubygems_version = %q{1.4.2}
82
82
  s.summary = %q{Standup is an application deployment and infrastructure management tool for Rails and Amazon EC2}
83
83
 
84
84
  if s.respond_to? :specification_version then
85
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
86
85
  s.specification_version = 3
87
86
 
88
87
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
89
88
  s.add_runtime_dependency(%q<trollop>, [">= 1.16"])
89
+ s.add_runtime_dependency(%q<i18n>, [">= 0.5.0"])
90
90
  s.add_runtime_dependency(%q<activesupport>, [">= 3.0"])
91
91
  s.add_runtime_dependency(%q<settingslogic>, [">= 2.0"])
92
92
  s.add_runtime_dependency(%q<amazon-ec2>, [">= 0.9"])
@@ -95,6 +95,7 @@ Gem::Specification.new do |s|
95
95
  s.add_runtime_dependency(%q<highline>, [">= 1.5.2"])
96
96
  else
97
97
  s.add_dependency(%q<trollop>, [">= 1.16"])
98
+ s.add_dependency(%q<i18n>, [">= 0.5.0"])
98
99
  s.add_dependency(%q<activesupport>, [">= 3.0"])
99
100
  s.add_dependency(%q<settingslogic>, [">= 2.0"])
100
101
  s.add_dependency(%q<amazon-ec2>, [">= 0.9"])
@@ -104,6 +105,7 @@ Gem::Specification.new do |s|
104
105
  end
105
106
  else
106
107
  s.add_dependency(%q<trollop>, [">= 1.16"])
108
+ s.add_dependency(%q<i18n>, [">= 0.5.0"])
107
109
  s.add_dependency(%q<activesupport>, [">= 3.0"])
108
110
  s.add_dependency(%q<settingslogic>, [">= 2.0"])
109
111
  s.add_dependency(%q<amazon-ec2>, [">= 0.9"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standup
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
4
+ hash: 51
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 15
10
- version: 0.3.15
9
+ - 16
10
+ version: 0.3.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilia Ablamonov
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-01-02 00:00:00 +03:00
20
+ date: 2011-01-14 00:00:00 +03:00
21
21
  default_executable: standup
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -36,9 +36,25 @@ dependencies:
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
39
- name: activesupport
39
+ name: i18n
40
40
  prerelease: false
41
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 11
47
+ segments:
48
+ - 0
49
+ - 5
50
+ - 0
51
+ version: 0.5.0
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: activesupport
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
42
58
  none: false
43
59
  requirements:
44
60
  - - ">="
@@ -49,11 +65,11 @@ dependencies:
49
65
  - 0
50
66
  version: "3.0"
51
67
  type: :runtime
52
- version_requirements: *id002
68
+ version_requirements: *id003
53
69
  - !ruby/object:Gem::Dependency
54
70
  name: settingslogic
55
71
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ">="
@@ -64,11 +80,11 @@ dependencies:
64
80
  - 0
65
81
  version: "2.0"
66
82
  type: :runtime
67
- version_requirements: *id003
83
+ version_requirements: *id004
68
84
  - !ruby/object:Gem::Dependency
69
85
  name: amazon-ec2
70
86
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
87
+ requirement: &id005 !ruby/object:Gem::Requirement
72
88
  none: false
73
89
  requirements:
74
90
  - - ">="
@@ -79,11 +95,11 @@ dependencies:
79
95
  - 9
80
96
  version: "0.9"
81
97
  type: :runtime
82
- version_requirements: *id004
98
+ version_requirements: *id005
83
99
  - !ruby/object:Gem::Dependency
84
100
  name: aws-s3
85
101
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
102
+ requirement: &id006 !ruby/object:Gem::Requirement
87
103
  none: false
88
104
  requirements:
89
105
  - - ">="
@@ -94,11 +110,11 @@ dependencies:
94
110
  - 5
95
111
  version: "0.5"
96
112
  type: :runtime
97
- version_requirements: *id005
113
+ version_requirements: *id006
98
114
  - !ruby/object:Gem::Dependency
99
115
  name: net-ssh
100
116
  prerelease: false
101
- requirement: &id006 !ruby/object:Gem::Requirement
117
+ requirement: &id007 !ruby/object:Gem::Requirement
102
118
  none: false
103
119
  requirements:
104
120
  - - ">="
@@ -109,11 +125,11 @@ dependencies:
109
125
  - 0
110
126
  version: "2.0"
111
127
  type: :runtime
112
- version_requirements: *id006
128
+ version_requirements: *id007
113
129
  - !ruby/object:Gem::Dependency
114
130
  name: highline
115
131
  prerelease: false
116
- requirement: &id007 !ruby/object:Gem::Requirement
132
+ requirement: &id008 !ruby/object:Gem::Requirement
117
133
  none: false
118
134
  requirements:
119
135
  - - ">="
@@ -125,7 +141,7 @@ dependencies:
125
141
  - 2
126
142
  version: 1.5.2
127
143
  type: :runtime
128
- version_requirements: *id007
144
+ version_requirements: *id008
129
145
  description:
130
146
  email: ilia@flamefork.ru
131
147
  executables:
@@ -223,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
239
  requirements: []
224
240
 
225
241
  rubyforge_project:
226
- rubygems_version: 1.3.7
242
+ rubygems_version: 1.4.2
227
243
  signing_key:
228
244
  specification_version: 3
229
245
  summary: Standup is an application deployment and infrastructure management tool for Rails and Amazon EC2