zfben_rails_rake 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zfben_rails_rake.rb +7 -16
- data/lib/zfben_rails_rake/helper.rb +5 -10
- data/lib/zfben_rails_rake/tasks/git.rb +9 -9
- data/lib/zfben_rails_rake/tasks/mongodb.rb +10 -10
- data/lib/zfben_rails_rake/tasks/resque.rb +13 -12
- data/lib/zfben_rails_rake/tasks/unicorn.rb +8 -10
- data/zfben_rails_rake.gemspec +1 -1
- metadata +5 -7
- data/bin/zfben +0 -6
data/lib/zfben_rails_rake.rb
CHANGED
@@ -1,19 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require ZfbenRailsRakePath + '/helper.rb'
|
9
|
-
Dir[File.join(ZfbenRailsRakePath, 'tasks', '*')].each{ |f| require f }
|
10
|
-
end
|
1
|
+
module ZfbenRailsRake
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
railtie_name :zfben_rails_rake
|
4
|
+
rake_tasks do
|
5
|
+
path = File.dirname(__FILE__) << '/zfben_rails_rake'
|
6
|
+
require path + '/helper.rb'
|
7
|
+
Dir[path + '/tasks/*.rb'].each{ |f| require f }
|
11
8
|
end
|
12
9
|
end
|
13
|
-
else
|
14
|
-
require ZfbenRailsRakePath + '/helper.rb'
|
15
|
-
Dir[File.join(ZfbenRailsRakePath, 'tasks', '*')].each{ |f| require f }
|
16
|
-
task :default do
|
17
|
-
p 'ok'
|
18
|
-
end
|
19
10
|
end
|
@@ -2,18 +2,13 @@ require 'rainbow'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
def
|
5
|
+
def zfben_rails_rake_system cmd
|
6
|
+
cmd = cmd
|
6
7
|
STDOUT.print (cmd + "\n").color(:green)
|
7
|
-
|
8
|
+
zfben_rails_rake_err unless system cmd
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
-
|
11
|
+
def zfben_rails_rake_err msg = 'Failed!'
|
12
|
+
STDERR.print (msg + "\n").color(:red)
|
12
13
|
exit!
|
13
14
|
end
|
14
|
-
|
15
|
-
if defined?(Rails) && !Rails.root.nil?
|
16
|
-
ROOT = File.realpath(Rails.root).to_s
|
17
|
-
else
|
18
|
-
ROOT = File.realpath('.').to_s
|
19
|
-
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
if File.exists?(
|
2
|
-
namespace :git do
|
1
|
+
if File.exists? Rails.root.join('.git')
|
2
|
+
namespace :git do
|
3
3
|
desc 'Git pull'
|
4
4
|
task :pull do
|
5
|
-
|
5
|
+
zfben_rails_rake_system 'git pull'
|
6
6
|
end
|
7
7
|
|
8
8
|
desc 'Git commit with your comment'
|
9
9
|
task :commit, [:comment] do |task, args|
|
10
10
|
args = args.to_hash
|
11
|
-
|
11
|
+
zfben_rails_rake_system "git add ."
|
12
12
|
comment = args.has_key?(:comment) ? args[:comment] : `git status`
|
13
|
-
|
13
|
+
zfben_rails_rake_system "git commit -m '#{comment}' -a"
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Git push with your comment'
|
17
17
|
task :push, [:comment] => [:commit] do |task, comment|
|
18
|
-
|
18
|
+
zfben_rails_rake_system 'git push'
|
19
19
|
end
|
20
20
|
|
21
21
|
desc 'Clear files in .gitignore'
|
22
22
|
task :clear do
|
23
|
-
unless File.exists?
|
24
|
-
|
23
|
+
unless File.exists? Rails.root.join('.gitignore')
|
24
|
+
zfben_rails_rake_err '.gitignore is not exists!'
|
25
25
|
else
|
26
|
-
|
26
|
+
zfben_rails_rake_system 'git clean -dfX'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
if File.exist?(
|
2
|
-
config = YAML.load(File.read(ROOT + '/config/mongoid.yml'))
|
1
|
+
if File.exist? Rails.root.join('config/mongoid.yml')
|
3
2
|
namespace :mongodb do
|
3
|
+
config = YAML.load(File.read(Rails.root.join('config/mongoid.yml')))
|
4
4
|
backup = "mongodump --host #{config['production']['host']} --port #{config['production']['port']}"
|
5
5
|
desc backup
|
6
6
|
task :dump do
|
7
|
-
|
7
|
+
zfben_rails_rake_system backup
|
8
8
|
end
|
9
9
|
|
10
10
|
restore = "mongorestore --host #{config['production']['host']} --port #{config['production']['port']}"
|
11
11
|
desc restore
|
12
12
|
task :restore do
|
13
|
-
|
13
|
+
zfben_rails_rake_system restore
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Start Mongodb'
|
17
17
|
task :start do
|
18
|
-
|
19
|
-
|
18
|
+
zfben_rails_rake_system "mkdir #{Rails.root}/mongo" unless File.exists?(Rails.root.join('mongo'))
|
19
|
+
zfben_rails_rake_system "mongod --nohttpinterface --nojournal --port #{config['production']['port']} --bind_ip #{config['production']['host']} --dbpath #{Rails.root}/mongo --fork --logpath #{Rails.root}/log/mongodb.log"
|
20
20
|
end
|
21
21
|
|
22
22
|
desc 'Stop Mongodb'
|
23
23
|
task :stop do
|
24
|
-
path =
|
24
|
+
path = Rails.root.join('mongo/mongod.lock').to_s
|
25
25
|
if File.exists?(path)
|
26
|
-
|
27
|
-
|
26
|
+
zfben_rails_rake_system "kill `cat #{path}`"
|
27
|
+
zfben_rails_rake_system 'rm ' + path
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
desc 'Clear mongo folder'
|
32
32
|
task :clear do
|
33
|
-
|
33
|
+
zfben_rails_rake_system 'rm -r mongo/*'
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -1,41 +1,42 @@
|
|
1
|
-
if File.exists?(
|
2
|
-
require ROOT + '/config/initializers/resque.rb'
|
3
|
-
require 'resque/tasks'
|
4
|
-
if defined?(Resque::Scheduler)
|
5
|
-
require 'resque_scheduler/tasks'
|
6
|
-
end
|
1
|
+
if File.exists? Rails.root.join('config/initializers/resque.rb')
|
7
2
|
namespace :resque do
|
3
|
+
require Rails.root.join('config/initializers/resque.rb')
|
4
|
+
require 'resque/tasks'
|
5
|
+
if defined?(Resque::Scheduler)
|
6
|
+
require 'resque_scheduler/tasks'
|
7
|
+
end
|
8
|
+
|
8
9
|
task :setup => :environment
|
9
10
|
|
10
11
|
task :_work => ['resque:preload', 'resque:setup'] do
|
11
12
|
work = Resque::Worker.new('*')
|
12
13
|
Process.daemon(true)
|
13
|
-
File.open(
|
14
|
+
File.open(Rails.root.join('tmp/resque.pid'), 'w') { |f| f << work.pid }
|
14
15
|
work.work(5)
|
15
16
|
end
|
16
17
|
|
17
18
|
if defined?(Resque::Scheduler)
|
18
19
|
task :_scheduler => 'resque:setup' do
|
19
20
|
Process.daemon(true)
|
20
|
-
File.open(
|
21
|
+
File.open(Rails.root.join('tmp/scheduler.pid'), 'w') { |f| f << Process.pid.to_s }
|
21
22
|
Resque::Scheduler.run
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
desc 'Start Resque daemon worker'
|
26
27
|
task :start => 'resque:stop' do
|
27
|
-
|
28
|
+
zfben_rails_rake_system "bash -c 'RAILS_ENV=production rake resque:_work'"
|
28
29
|
if defined?(Resque::Scheduler)
|
29
|
-
|
30
|
+
zfben_rails_rake_system "bash -c 'RAILS_ENV=production rake resque:_scheduler'"
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
desc 'Stop Resque worker'
|
34
35
|
task :stop do
|
35
36
|
['resque', 'scheduler'].each do |name|
|
36
|
-
path =
|
37
|
+
path = Rails.root.join('tmp/' + name + '.pid')
|
37
38
|
if File.exists?(path)
|
38
|
-
|
39
|
+
zfben_rails_rake_system "kill `cat #{path}`;rm #{path}"
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -1,27 +1,25 @@
|
|
1
|
-
if File.exists?
|
1
|
+
if File.exists? Rails.root.join('unicorn.rb')
|
2
2
|
namespace :unicorn do
|
3
3
|
desc 'Start unicorn server'
|
4
4
|
task :start do
|
5
|
-
if File.exists?
|
5
|
+
if File.exists? Rails.root.join('config.ru')
|
6
6
|
cmd = 'unicorn'
|
7
7
|
else
|
8
8
|
cmd = 'unicorn_rails'
|
9
9
|
end
|
10
|
-
|
10
|
+
zfben_rails_rake_system cmd << ' -c unicorn.rb -E production -D'
|
11
11
|
end
|
12
12
|
|
13
13
|
desc 'Stop unicorn server'
|
14
14
|
task :stop do
|
15
|
-
if File.exists?
|
16
|
-
|
15
|
+
if File.exists? Rails.root.join('tmp/unicorn.pid')
|
16
|
+
zfben_rails_rake_system 'kill -QUIT `cat tmp/unicorn.pid`'
|
17
17
|
sleep 1
|
18
18
|
end
|
19
|
-
|
19
|
+
zfben_rails_rake_system 'rm -r tmp/*'
|
20
20
|
end
|
21
21
|
|
22
|
-
desc '
|
23
|
-
task :restart
|
24
|
-
sys 'kill -HUP `cat tmp/unicorn.pid`'
|
25
|
-
end
|
22
|
+
desc 'Restart unicorn server'
|
23
|
+
task :restart => [:stop, :start]
|
26
24
|
end
|
27
25
|
end
|
data/zfben_rails_rake.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zfben_rails_rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
16
|
-
requirement: &
|
16
|
+
requirement: &11135260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,12 +21,11 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11135260
|
25
25
|
description: ''
|
26
26
|
email:
|
27
27
|
- ben@zfben.com
|
28
|
-
executables:
|
29
|
-
- zfben
|
28
|
+
executables: []
|
30
29
|
extensions: []
|
31
30
|
extra_rdoc_files: []
|
32
31
|
files:
|
@@ -34,7 +33,6 @@ files:
|
|
34
33
|
- Gemfile
|
35
34
|
- README.rdoc
|
36
35
|
- Rakefile
|
37
|
-
- bin/zfben
|
38
36
|
- lib/zfben_rails_rake.rb
|
39
37
|
- lib/zfben_rails_rake/helper.rb
|
40
38
|
- lib/zfben_rails_rake/tasks/git.rb
|