ratchetify 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ratchetify/db.rb +49 -0
- data/lib/ratchetify/php.rb +1 -1
- data/lib/ratchetify/rails.rb +4 -52
- data/lib/ratchetify/service.rb +18 -2
- data/lib/ratchetify/undeploy.rb +2 -6
- data/lib/ratchetify/version.rb +1 -1
- data/lib/ratchetify/wordpress.rb +4 -35
- data/lib/ratchetify.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a4b8fdc1b6691a5ca19a8c95f91378178668bf7
|
4
|
+
data.tar.gz: e301d5942f39c709b69c8f434dab192d63882fae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d620f93eee909490c77afcb898ef4842997f91cbe23a058c15e559dc2de18b125142c68f19489f0437fd2e0e5a2d25cb9aaf97da8f9459976cfca4135ce29e2
|
7
|
+
data.tar.gz: ce3371bd8f427d0113de5a38db17d00d20784af94a999a6961cae738534aecf3944fa7d3c82a7edc1e905357e090094fd7caf1edbad592fdb1898916152b0476
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
Capistrano::Configuration.instance.load do
|
3
|
+
|
4
|
+
require 'capistrano'
|
5
|
+
require 'ratchetify/helpers'
|
6
|
+
|
7
|
+
desc "Tasks to create / drop a database (mysql)"
|
8
|
+
namespace :db do
|
9
|
+
|
10
|
+
task :create do
|
11
|
+
|
12
|
+
# extract user & password
|
13
|
+
my_cnf = capture('cat ~/.my.cnf')
|
14
|
+
|
15
|
+
my_cnf.match(/^user=(\w+)/)
|
16
|
+
mysql_user = $1
|
17
|
+
my_cnf.match(/^password=(\w+)/)
|
18
|
+
mysql_pwd = $1
|
19
|
+
|
20
|
+
# create the database
|
21
|
+
mysql_database = "#{user}_#{application}" # 'application' MUST NOT contain any '-' !!!
|
22
|
+
run "mysql -e 'CREATE DATABASE IF NOT EXISTS #{mysql_database} CHARACTER SET utf8 COLLATE utf8_general_ci;'"
|
23
|
+
|
24
|
+
# create the database.yml file
|
25
|
+
database_yml = <<-EOF
|
26
|
+
production:
|
27
|
+
adapter: mysql2
|
28
|
+
encoding: utf8
|
29
|
+
database: #{mysql_database}
|
30
|
+
pool: 15
|
31
|
+
username: #{mysql_user}
|
32
|
+
password: #{mysql_pwd}
|
33
|
+
host: localhost
|
34
|
+
socket: /var/lib/mysql/mysql.sock
|
35
|
+
timeout: 10000
|
36
|
+
|
37
|
+
EOF
|
38
|
+
# upload the database.yml file
|
39
|
+
put database_yml, "#{deploy_dir}/config/database.yml"
|
40
|
+
|
41
|
+
end # task :create
|
42
|
+
|
43
|
+
task :drop do
|
44
|
+
mysql_database = "#{user}_#{application}" # 'application' MUST NOT contain any '-' !!!
|
45
|
+
run "mysql -e 'DROP DATABASE IF EXISTS #{mysql_database};'"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
data/lib/ratchetify/php.rb
CHANGED
data/lib/ratchetify/rails.rb
CHANGED
@@ -6,19 +6,20 @@ Capistrano::Configuration.instance.load do
|
|
6
6
|
require 'ratchetify/setup'
|
7
7
|
require 'ratchetify/domain'
|
8
8
|
require 'ratchetify/service'
|
9
|
+
require 'ratchetify/db'
|
9
10
|
|
10
11
|
before "create:rails", "setup:environment"
|
12
|
+
before "create:rails", "db:create"
|
11
13
|
after "create:rails", "service:create"
|
14
|
+
after "create:rails", "service:create_reverse_proxy"
|
12
15
|
after "create:rails", "domain:add"
|
13
16
|
|
14
17
|
desc "Deploy an app for the first time"
|
15
18
|
namespace :create do
|
16
19
|
|
17
|
-
desc "Deploy
|
20
|
+
desc "Deploy a RAILS app to uberspace"
|
18
21
|
task :rails do
|
19
22
|
create_repo
|
20
|
-
create_and_configure_database
|
21
|
-
create_reverse_proxy
|
22
23
|
config_rails_app
|
23
24
|
finalize
|
24
25
|
end
|
@@ -40,55 +41,6 @@ Capistrano::Configuration.instance.load do
|
|
40
41
|
|
41
42
|
end # task :create_repo
|
42
43
|
|
43
|
-
task :create_and_configure_database do
|
44
|
-
|
45
|
-
# extract user & password
|
46
|
-
my_cnf = capture('cat ~/.my.cnf')
|
47
|
-
|
48
|
-
my_cnf.match(/^user=(\w+)/)
|
49
|
-
mysql_user = $1
|
50
|
-
my_cnf.match(/^password=(\w+)/)
|
51
|
-
mysql_pwd = $1
|
52
|
-
|
53
|
-
# create the database
|
54
|
-
mysql_database = "#{user}_#{application}" # 'application' MUST NOT contain any '-' !!!
|
55
|
-
run "mysql -e 'CREATE DATABASE IF NOT EXISTS #{mysql_database} CHARACTER SET utf8 COLLATE utf8_general_ci;'"
|
56
|
-
|
57
|
-
# create the database.yml file
|
58
|
-
database_yml = <<-EOF
|
59
|
-
production:
|
60
|
-
adapter: mysql2
|
61
|
-
encoding: utf8
|
62
|
-
database: #{mysql_database}
|
63
|
-
pool: 15
|
64
|
-
username: #{mysql_user}
|
65
|
-
password: #{mysql_pwd}
|
66
|
-
host: localhost
|
67
|
-
socket: /var/lib/mysql/mysql.sock
|
68
|
-
timeout: 10000
|
69
|
-
|
70
|
-
EOF
|
71
|
-
# upload the database.yml file
|
72
|
-
put database_yml, "#{deploy_dir}/config/database.yml"
|
73
|
-
|
74
|
-
end # task :create_and_configure_database
|
75
|
-
|
76
|
-
task :create_reverse_proxy do
|
77
|
-
|
78
|
-
# .htaccess
|
79
|
-
htaccess = <<-EOF
|
80
|
-
RewriteEngine On
|
81
|
-
RewriteBase /
|
82
|
-
RewriteCond %{REQUEST_FILENAME} !-f
|
83
|
-
RewriteRule ^(.*)$ http://localhost:#{daemon_port}/$1 [P]
|
84
|
-
EOF
|
85
|
-
|
86
|
-
# place the .htaccess file
|
87
|
-
put htaccess, "#{deploy_dir}/.htaccess"
|
88
|
-
run "chmod +r #{deploy_dir}/.htaccess"
|
89
|
-
|
90
|
-
end # task :create_reverse_proxy
|
91
|
-
|
92
44
|
task :config_rails_app do
|
93
45
|
# run bundle install first
|
94
46
|
run "cd #{deploy_dir} && bundle install --path ~/.gem"
|
data/lib/ratchetify/service.rb
CHANGED
@@ -36,7 +36,7 @@ Capistrano::Configuration.instance.load do
|
|
36
36
|
export HOME=/home/#{user}
|
37
37
|
source $HOME/.bash_profile
|
38
38
|
cd #{deploy_dir}
|
39
|
-
exec /home/#{user}/.gem/ruby/#{
|
39
|
+
exec /home/#{user}/.gem/ruby/#{:ruby_api_version}/bin/bundle exec thin start -p #{daemon_port} -e production 2>&1
|
40
40
|
EOF
|
41
41
|
|
42
42
|
# upload the run script
|
@@ -52,7 +52,7 @@ EOF
|
|
52
52
|
export HOME=/home/#{user}
|
53
53
|
source $HOME/.bash_profile
|
54
54
|
cd #{deploy_dir}
|
55
|
-
exec /home/#{user}/.gem/ruby/#{
|
55
|
+
exec /home/#{user}/.gem/ruby/#{:ruby_api_version}/bin/bundle exec unicorn -p #{daemon_port} -c ./config/unicorn.rb -E #{environment} 2>&1
|
56
56
|
EOF
|
57
57
|
|
58
58
|
# upload the run script
|
@@ -91,6 +91,22 @@ EOF
|
|
91
91
|
|
92
92
|
end # task :create_service_unicorn
|
93
93
|
|
94
|
+
task :create_reverse_proxy do
|
95
|
+
|
96
|
+
# .htaccess
|
97
|
+
htaccess = <<-EOF
|
98
|
+
RewriteEngine On
|
99
|
+
RewriteBase /
|
100
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
101
|
+
RewriteRule ^(.*)$ http://localhost:#{daemon_port}/$1 [P]
|
102
|
+
EOF
|
103
|
+
|
104
|
+
# place the .htaccess file
|
105
|
+
put htaccess, "#{deploy_dir}/.htaccess"
|
106
|
+
run "chmod +r #{deploy_dir}/.htaccess"
|
107
|
+
|
108
|
+
end # task :create_reverse_proxy
|
109
|
+
|
94
110
|
desc "Remove the service"
|
95
111
|
task :remove do
|
96
112
|
script = <<-EOF
|
data/lib/ratchetify/undeploy.rb
CHANGED
@@ -4,23 +4,19 @@ Capistrano::Configuration.instance.load do
|
|
4
4
|
require 'capistrano'
|
5
5
|
require 'ratchetify/helpers'
|
6
6
|
require 'ratchetify/service'
|
7
|
+
require 'ratchetify/db'
|
7
8
|
|
8
9
|
before "undeploy", "service:remove"
|
10
|
+
before "undeploy", "db:drop"
|
9
11
|
|
10
12
|
desc "Undeploy an app from uberspace"
|
11
13
|
namespace :undeploy do
|
12
14
|
|
13
15
|
desc "Undeploy an app from uberspace"
|
14
16
|
task :default do
|
15
|
-
drop_database
|
16
17
|
remove_repo
|
17
18
|
end
|
18
19
|
|
19
|
-
task :drop_database do
|
20
|
-
mysql_database = "#{user}_#{application}" # 'application' MUST NOT contain any '-' !!!
|
21
|
-
run "mysql -e 'DROP DATABASE IF EXISTS #{mysql_database};'"
|
22
|
-
end
|
23
|
-
|
24
20
|
task :remove_repo do
|
25
21
|
run "cd #{deploy_root} && rm -rf #{fetch :application}"
|
26
22
|
run "cd #{webroot_dir} && rm -rf #{fetch :host}.#{fetch :domain}"
|
data/lib/ratchetify/version.rb
CHANGED
data/lib/ratchetify/wordpress.rb
CHANGED
@@ -5,17 +5,18 @@ Capistrano::Configuration.instance.load do
|
|
5
5
|
require 'ratchetify/helpers'
|
6
6
|
require 'ratchetify/setup'
|
7
7
|
require 'ratchetify/domain'
|
8
|
+
require 'ratchetify/db'
|
8
9
|
|
9
10
|
before "create:wordpress", "setup:environment"
|
11
|
+
before "create:wordpress", "db:create"
|
10
12
|
after "create:wordpress", "domain:add"
|
11
13
|
|
12
14
|
desc "Deploy an app for the first time"
|
13
15
|
namespace :create do
|
14
16
|
|
15
|
-
desc "Deploy
|
17
|
+
desc "Deploy a standard wordpress blog to uberspace"
|
16
18
|
task :wordpress do
|
17
19
|
create_web_dir
|
18
|
-
create_database
|
19
20
|
finalize
|
20
21
|
end
|
21
22
|
|
@@ -33,42 +34,10 @@ Capistrano::Configuration.instance.load do
|
|
33
34
|
#run "cd #{deploy_root} && rm wordpress*"
|
34
35
|
run "cd #{webroot_dir} && rm -rf wordpress*"
|
35
36
|
|
36
|
-
# rename word press to -> :application
|
37
|
-
#run "cd #{deploy_root} && mv ./wordpress #{application}"
|
38
37
|
end
|
39
38
|
|
40
39
|
end # task :create_dir
|
41
|
-
|
42
|
-
task :create_database do
|
43
|
-
|
44
|
-
# extract user & password
|
45
|
-
my_cnf = capture('cat ~/.my.cnf')
|
46
|
-
|
47
|
-
my_cnf.match(/^user=(\w+)/)
|
48
|
-
mysql_user = $1
|
49
|
-
my_cnf.match(/^password=(\w+)/)
|
50
|
-
mysql_pwd = $1
|
51
|
-
my_cnf.match(/^port=(\w+)/)
|
52
|
-
mysql_port = $1
|
53
|
-
|
54
|
-
# create the database
|
55
|
-
mysql_database = "#{user}_#{application}" # 'application' MUST NOT contain any '-' !!!
|
56
|
-
run "mysql -e 'CREATE DATABASE IF NOT EXISTS #{mysql_database} CHARACTER SET utf8 COLLATE utf8_general_ci;'"
|
57
|
-
|
58
|
-
database_yml = <<-EOF
|
59
|
-
database: #{mysql_database}
|
60
|
-
username: #{mysql_user}
|
61
|
-
password: #{mysql_pwd}
|
62
|
-
host: localhost
|
63
|
-
port: #{mysql_port}
|
64
|
-
|
65
|
-
EOF
|
66
|
-
|
67
|
-
# upload the database.yml file
|
68
|
-
put database_yml, "#{deploy_dir}/database.yml"
|
69
|
-
|
70
|
-
end # task :create_database
|
71
|
-
|
40
|
+
|
72
41
|
task :finalize do
|
73
42
|
# create symbolic links..
|
74
43
|
run "cd #{webroot_dir} && ln -s #{deploy_dir} #{fetch :host}.#{fetch :domain}"
|
data/lib/ratchetify.rb
CHANGED
@@ -11,7 +11,9 @@ Capistrano::Configuration.instance.load do
|
|
11
11
|
require 'ratchetify/domain'
|
12
12
|
require 'ratchetify/rails'
|
13
13
|
require 'ratchetify/wordpress'
|
14
|
+
require 'ratchetify/php'
|
14
15
|
require 'ratchetify/update'
|
16
|
+
require 'ratchetify/db'
|
15
17
|
require 'ratchetify/help' # monkey patched from capistrano
|
16
18
|
|
17
19
|
# host and domain for the new app
|
@@ -21,7 +23,7 @@ Capistrano::Configuration.instance.load do
|
|
21
23
|
|
22
24
|
# random port used for the reverse proxy
|
23
25
|
set :daemon_port, rand(61000-32768+1)+32768 # random port
|
24
|
-
set :type, :rails # supported types are: :rails, :wordpress,
|
26
|
+
set :type, :rails # supported types are: :rails, :wordpress, :php
|
25
27
|
|
26
28
|
# internal variables, should not be changed in the cap file
|
27
29
|
set :ruby_version, "2.1.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratchetify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Kuehl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- bin/rat
|
57
57
|
- lib/ratchetify.rb
|
58
58
|
- lib/ratchetify/base.rb
|
59
|
+
- lib/ratchetify/db.rb
|
59
60
|
- lib/ratchetify/domain.rb
|
60
61
|
- lib/ratchetify/help.rb
|
61
62
|
- lib/ratchetify/helpers.rb
|