ztil 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/lib/ztil.rb +1 -1
- data/lib/ztil/command.rb +41 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8529f38fd370f29a03cb680bf068b8b2f17a5dd4
|
4
|
+
data.tar.gz: b05ff95a09c988900943a2d99e0f4dfa24d65a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cbb550bf9e5f12a9c285cd6b8968ce602b2e623d8801bfa40fd11caa3ba59ba9d407b97cc65d17b21911548dca136cec1f23d2dc90e6c58d5236f6d0323b2c2
|
7
|
+
data.tar.gz: 492790829728ea16e89cb7beee332fb2e62b3d8edd6f93798a0cc52a147dfcc46ffe659196f2638dcfc4ad92669d8ff5fc41332c519ffd68cd5a3fb4b0eba5c9
|
data/lib/ztil.rb
CHANGED
data/lib/ztil/command.rb
CHANGED
@@ -28,9 +28,9 @@ module Ztil
|
|
28
28
|
# ztil backup --databases="mysql,mongodb" --storages="qi_niu" --email="xxx@xxx.com" --schedule="1.day&4:30 am" --run_prefix="bundle exec"
|
29
29
|
desc 'backup DATABASE_NAME', '备份数据库, DATABASE_NAME最好为数据库名称(可修改)'
|
30
30
|
method_option :databases, desc: '需要备份的数据库类型, 支持(mongodb, mysql, openldap, postgresql, redis, riak)', required: true, aliases: 'd'
|
31
|
-
method_option :storages, desc: '备份数据的存储方式, 支持存储到七牛(
|
31
|
+
method_option :storages, desc: '备份数据的存储方式, 支持存储到七牛(qi_niu), 本地(local)', aliases: 's'
|
32
32
|
method_option :email, desc: '备份成功后通知的邮箱', aliases: 'e'
|
33
|
-
method_option :schedule, desc: '按计划执行,
|
33
|
+
method_option :schedule, desc: '按计划执行, 默认只执行一次, eq: `1.day&4:30 am`', aliases: 'S'
|
34
34
|
method_option :run_prefix, desc: '运行任务命令的前缀, 例如`bundle exec`', aliases: 'r'
|
35
35
|
def backup(name)
|
36
36
|
storages = options[:storages] || 'local'
|
@@ -112,5 +112,44 @@ module Ztil
|
|
112
112
|
run "ruby -run -ehttpd . -p#{options[:port]}"
|
113
113
|
end
|
114
114
|
|
115
|
+
# 在当前rails目录下安装capistrano
|
116
|
+
# https://github.com/zires/capistrano-3-rails-template
|
117
|
+
desc 'cap_me[PATH]', "在当前目录下安装capistrano的支持"
|
118
|
+
def cap_me(path = nil)
|
119
|
+
path ||= '.'
|
120
|
+
gemfile = File.expand_path("#{path}/Gemfile")
|
121
|
+
|
122
|
+
raise "Can't find Gemfile #{gemfile}" unless File.exists?(gemfile)
|
123
|
+
|
124
|
+
append_to_file gemfile do
|
125
|
+
<<-GEMS
|
126
|
+
|
127
|
+
### Add by cap me
|
128
|
+
gem 'unicorn'
|
129
|
+
group :development do
|
130
|
+
gem 'capistrano', '>= 3.1.0'
|
131
|
+
gem 'capistrano-rails', '>= 1.1.0'
|
132
|
+
gem 'capistrano-bundler'
|
133
|
+
gem 'capistrano-rbenv', '>= 2.0'
|
134
|
+
end
|
135
|
+
|
136
|
+
GEMS
|
137
|
+
end
|
138
|
+
|
139
|
+
run "cd #{path} && bundle install && bundle exec cap install"
|
140
|
+
|
141
|
+
tmp_dir = Dir.mktmpdir
|
142
|
+
run "git clone https://github.com/zires/capistrano-3-rails-template.git #{tmp_dir}"
|
143
|
+
run "cp -R #{tmp_dir}/config #{path}/"
|
144
|
+
run "cp -R #{tmp_dir}/lib #{path}/"
|
145
|
+
|
146
|
+
uncomment_lines File.join(path, 'Capfile'), /require.+rbenv/
|
147
|
+
uncomment_lines File.join(path, 'Capfile'), /require.+bundler/
|
148
|
+
uncomment_lines File.join(path, 'Capfile'), /require.+rails/
|
149
|
+
|
150
|
+
run "cd #{path} && bundle exec cap production deploy --dry-run"
|
151
|
+
|
152
|
+
end
|
153
|
+
|
115
154
|
end
|
116
155
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zires
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|