standup 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/standup/core_ext.rb +1 -1
- data/lib/standup/remoting.rb +4 -1
- data/scripts/db_backup.rb +1 -1
- data/scripts/download_db.rb +1 -26
- data/scripts/ec2.rb +2 -0
- data/scripts/mysql.rb +8 -13
- data/scripts/passenger/nginx.conf +2 -2
- data/scripts/passenger.rb +1 -3
- data/scripts/postgresql/pg_hba.conf +3 -0
- data/scripts/postgresql.rb +14 -18
- data/scripts/upload_db.rb +2 -2
- data/scripts/webapp.rb +1 -2
- data/standup.gemspec +3 -2
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.11
|
data/lib/standup/core_ext.rb
CHANGED
data/lib/standup/remoting.rb
CHANGED
@@ -77,7 +77,7 @@ module Standup
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def su_exec user, command
|
80
|
-
sudo "
|
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
|
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
|
data/scripts/download_db.rb
CHANGED
@@ -10,33 +10,8 @@ Standup.script :node do
|
|
10
10
|
:sudo => true
|
11
11
|
end
|
12
12
|
|
13
|
-
|
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
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
|
-
|
11
|
-
|
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
|
-
|
18
|
-
true
|
14
|
+
exec command
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
|
-
def create_database name,
|
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
|
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.
|
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
|
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
|
data/scripts/postgresql.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
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
|
-
|
23
|
-
true
|
23
|
+
exec command
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def create_database name,
|
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}
|
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
|
-
"
|
37
|
+
"pg_dump -c #{database} -U #{username} -w"
|
38
38
|
end
|
39
39
|
|
40
40
|
def load_command database, username = 'postgres', *args
|
41
|
-
|
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
|
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
|
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.
|
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.
|
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-
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
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-
|
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
|