standup 0.3.10 → 0.3.11

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.10
1
+ 0.3.11
@@ -10,6 +10,6 @@ module Kernel
10
10
 
11
11
  def local_exec command
12
12
  bright_p command
13
- `#{command}`
13
+ `#{command} 2>&1`.tap{|result| puts result}
14
14
  end
15
15
  end
@@ -77,7 +77,7 @@ module Standup
77
77
  end
78
78
 
79
79
  def su_exec user, command
80
- sudo "su -c \"#{command.gsub /"/, '\"'}\" #{user}"
80
+ sudo "-u #{user} \"#{command.gsub /"/, '\"'}\""
81
81
  end
82
82
 
83
83
  def in_temp_dir &block
@@ -102,10 +102,13 @@ module Standup
102
102
  if version
103
103
  unless exec("gem list | grep #{name}").try(:[], version)
104
104
  sudo "gem install #{name} -v #{version} --no-ri --no-rdoc"
105
+ return true
105
106
  end
106
107
  else
107
108
  sudo "gem install #{name} --no-ri --no-rdoc"
109
+ return true
108
110
  end
111
+ false
109
112
  end
110
113
 
111
114
  def update_cron schedule, commands, opts = {}
data/scripts/db_backup.rb CHANGED
@@ -3,7 +3,7 @@ Standup.script :node do
3
3
  exec "s3cmd mb #{bucket}"
4
4
 
5
5
  update_cron '@hourly', <<-CMD, :section => name
6
- #{scripts.webapp.db.dump_command scripts.webapp.db_name, 'webapp', 'webapp'} | gzip > dump.gz
6
+ #{scripts.webapp.db.dump_command scripts.webapp.db_name} | gzip > dump.gz
7
7
  s3cmd put dump.gz #{path_prefix}/`date -u +%Y-%m-%d/%H-%M-%S`.gz
8
8
  rm dump.gz
9
9
  CMD
@@ -10,33 +10,8 @@ Standup.script :node do
10
10
  :sudo => true
11
11
  end
12
12
 
13
- create_user 'webapp', 'webapp'
14
- create_database scripts.webapp.db_name, 'webapp'
13
+ scripts.webapp.db.create_database scripts.webapp.db_name, true
15
14
 
16
15
  local_exec "#{scripts.webapp.db.load_command scripts.webapp.db_name} < tmp/db/dump.sql"
17
16
  end
18
-
19
- def create_user name, password
20
- if exec_sql("select user from mysql.user where user = '#{name}'").present?
21
- false
22
- else
23
- exec_sql "create user '#{name}'@'localhost' identified by '#{password}'"
24
- true
25
- end
26
- end
27
-
28
- def create_database name, owner
29
- if exec_sql("show databases like '#{name}'").present?
30
- false
31
- else
32
- exec_sql "create database #{name}"
33
- exec_sql "grant all on #{name}.* to '#{owner}'@'localhost'"
34
- true
35
- end
36
- end
37
-
38
-
39
- def exec_sql sql, db_name = 'mysql'
40
- local_exec "mysql -uroot -proot #{db_name} -e \"#{sql}\""
41
- end
42
17
  end
data/scripts/ec2.rb CHANGED
@@ -39,6 +39,8 @@ Standup.script :node do
39
39
  [Standup::EC2::SecurityGroup.list[node.id_group]]
40
40
  puts "waiting until it's up"
41
41
  inst.wait_until {inst.state != :running}
42
+ puts "and a bit more to let it really up"
43
+ sleep 20
42
44
  end
43
45
 
44
46
  def configure_elastic_ip
data/scripts/mysql.rb CHANGED
@@ -6,25 +6,20 @@ Standup.script :node do
6
6
  # todo: tune performance
7
7
  end
8
8
 
9
- def exec_sql sql
10
- exec "mysql -uroot -proot -e \"#{sql}\""
11
- end
12
-
13
- def create_user name, password
14
- if exec_sql("select user from mysql.user where user = '#{name}'").present?
15
- false
9
+ def exec_sql sql, local = false
10
+ command = "mysql -uroot -proot -e \"#{sql}\""
11
+ if local
12
+ local_exec command
16
13
  else
17
- exec_sql "create user '#{name}'@'localhost' identified by '#{password}'"
18
- true
14
+ exec command
19
15
  end
20
16
  end
21
17
 
22
- def create_database name, owner
23
- if exec_sql("show databases like '#{name}'").present?
18
+ def create_database name, local = false
19
+ if exec_sql("show databases like '#{name}'", local).present?
24
20
  false
25
21
  else
26
- exec_sql "create database #{name}"
27
- exec_sql "grant all on #{name}.* to '#{owner}'@'localhost'"
22
+ exec_sql "create database #{name}", local
28
23
  true
29
24
  end
30
25
  end
@@ -1,5 +1,5 @@
1
1
  user www-data;
2
- worker_processes 1;
2
+ worker_processes 2;
3
3
 
4
4
  pid /var/run/nginx.pid;
5
5
 
@@ -8,7 +8,7 @@ events {
8
8
  }
9
9
 
10
10
  http {
11
- passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.0;
11
+ passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.1;
12
12
  passenger_ruby /usr/local/bin/ruby;
13
13
 
14
14
  include mime.types;
data/scripts/passenger.rb CHANGED
@@ -2,9 +2,7 @@ Standup.script :node do
2
2
  def run
3
3
  scripts.ec2.open_port 80
4
4
 
5
- install_gem 'passenger', '3.0.0'
6
-
7
- unless file_exists? '/opt/nginx/sbin/nginx'
5
+ if install_gem('passenger', '3.0.1') || !file_exists?('/opt/nginx/sbin/nginx')
8
6
  install_package 'libcurl4-openssl-dev'
9
7
  sudo 'passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx'
10
8
  end
@@ -0,0 +1,3 @@
1
+ local all all trust
2
+ host all all 127.0.0.1/32 trust
3
+ host all all ::1/128 trust
@@ -2,6 +2,10 @@ Standup.script :node do
2
2
  def run
3
3
  install_packages 'postgresql-8.4 libpq-dev'
4
4
 
5
+ upload script_file('pg_hba.conf'),
6
+ :to => '/etc/postgresql/8.4/main/pg_hba.conf',
7
+ :sudo => true
8
+
5
9
  upload script_file('postgresql.conf'),
6
10
  :to => '/etc/postgresql/8.4/main/postgresql.conf',
7
11
  :sudo => true
@@ -11,38 +15,30 @@ Standup.script :node do
11
15
  sudo 'service postgresql-8.4 restart'
12
16
  end
13
17
 
14
- def exec_sql sql
15
- su_exec 'postgres', "psql -c \"#{sql}\""
16
- end
17
-
18
- def create_user name, password
19
- if exec_sql("select * from pg_user where usename = '#{name}'") =~ /1 row/
20
- false
18
+ def exec_sql sql, local = false
19
+ command = "psql -c \"#{sql}\" -U postgres -w"
20
+ if local
21
+ local_exec command
21
22
  else
22
- exec_sql "create user #{name} with password '#{password}'"
23
- true
23
+ exec command
24
24
  end
25
25
  end
26
26
 
27
- def create_database name, owner
28
- if exec_sql("select * from pg_database where datname = '#{name}'") =~ /1 row/
27
+ def create_database name, local = false
28
+ if exec_sql("select * from pg_database where datname = '#{name}'", local) =~ /1 row/
29
29
  false
30
30
  else
31
- exec_sql "create database #{name} with owner #{owner}"
31
+ exec_sql "create database #{name}", local
32
32
  true
33
33
  end
34
34
  end
35
35
 
36
36
  def dump_command database, username = 'postgres', *args
37
- "sudo su -c \"pg_dump -c #{database}\" #{username}"
37
+ "pg_dump -c #{database} -U #{username} -w"
38
38
  end
39
39
 
40
40
  def load_command database, username = 'postgres', *args
41
- if username == :local
42
- "psql #{database}"
43
- else
44
- "sudo su -c \"psql #{database}\" #{username}"
45
- end
41
+ "psql #{database} -U #{username} -w"
46
42
  end
47
43
 
48
44
  protected
data/scripts/upload_db.rb CHANGED
@@ -3,14 +3,14 @@ Standup.script :node do
3
3
 
4
4
  def run
5
5
  local_exec "mkdir -p tmp/db"
6
- local_exec "#{scripts.webapp.db.dump_command scripts.webapp.db_name, 'webapp', 'webapp'} > tmp/db/dump.sql"
6
+ local_exec "#{scripts.webapp.db.dump_command scripts.webapp.db_name} > tmp/db/dump.sql"
7
7
 
8
8
  in_temp_dir do |dir|
9
9
  upload 'tmp/db/dump.sql',
10
10
  :to => "#{dir}/dump.sql"
11
11
  exec "chmod 777 #{dir}/dump.sql"
12
12
 
13
- exec "#{scripts.webapp.db.load_command scripts.webapp.db_name, 'webapp', 'webapp'} < #{dir}/dump.sql"
13
+ exec "#{scripts.webapp.db.load_command scripts.webapp.db_name} < #{dir}/dump.sql"
14
14
  end
15
15
  end
16
16
  end
data/scripts/webapp.rb CHANGED
@@ -63,8 +63,7 @@ Standup.script :node do
63
63
  end
64
64
 
65
65
  def bootstrap_db
66
- db.create_user 'webapp', 'webapp'
67
- if db.create_database db_name, 'webapp'
66
+ if db.create_database db_name
68
67
  in_dir scripts.webapp.app_path do
69
68
  sudo 'bundle install'
70
69
  exec "RAILS_ENV=#{params.rails_env} rake db:schema:load"
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.10"
8
+ s.version = "0.3.11"
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", "Cloud Castle Inc."]
12
- s.date = %q{2010-12-06}
12
+ s.date = %q{2010-12-07}
13
13
  s.default_executable = %q{standup}
14
14
  s.email = %q{ilia@flamefork.ru}
15
15
  s.executables = ["standup"]
@@ -62,6 +62,7 @@ Gem::Specification.new do |s|
62
62
  "scripts/passenger/nginx.conf",
63
63
  "scripts/passenger/nginx_monit.conf",
64
64
  "scripts/postgresql.rb",
65
+ "scripts/postgresql/pg_hba.conf",
65
66
  "scripts/postgresql/postgresql.conf",
66
67
  "scripts/ruby.rb",
67
68
  "scripts/setup.rb",
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: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 10
10
- version: 0.3.10
9
+ - 11
10
+ version: 0.3.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilia Ablamonov
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-06 00:00:00 +03:00
19
+ date: 2010-12-07 00:00:00 +03:00
20
20
  default_executable: standup
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -179,6 +179,7 @@ files:
179
179
  - scripts/passenger/nginx.conf
180
180
  - scripts/passenger/nginx_monit.conf
181
181
  - scripts/postgresql.rb
182
+ - scripts/postgresql/pg_hba.conf
182
183
  - scripts/postgresql/postgresql.conf
183
184
  - scripts/ruby.rb
184
185
  - scripts/setup.rb