-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
91 lines (75 loc) · 2.55 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
desc "Parse Onliner's product pages and fill database's tables, use the d-argument for running as a daemon and the q-argument for a sidekiq queue filling"
task :parse, [:arg1, :arg2] do |t, args|
Rake::Task['environment'].invoke
require './lib/parser'
as_daemon =
if Hash[args].has_value?('d')
puts "WARNING: Argument 'd' found. Running parser as daemon"
true
end || false
with_queue =
if Hash[args].has_value?('q')
puts "WARNING: Argument 'q' found. Running parser with queue filling"
true
end || false
Parser.new.run(as_daemon, with_queue)
end
desc 'Reset the migrations.'
task :reset do
system('rake db:rollback STEP=8 && rake db:migrate')
end
desc 'Start to parse right after resetting the migrations.'
task :reparse => [:environment, :reset, :parse] do
end
desc "Run special script for filling 'Sellers'-table. Use it only if 'Costs'-table has been filled."
task :fill => :environment do
require './lib/sellers_filler'
Filler.run
end
desc 'Stop the application on the server, deploy from Github and start it again.'
task :deploy do
Rake::Task['remote:stop'].invoke
system('bundle exec cap production deploy')
Rake::Task['remote:start'].invoke
end
desc "Start the sidekiq process to fill 'Costs'-table."
task :sk do
system('bundle exec sidekiq -C config/sidekiq.yml -d')
end
desc 'Kill the sidekiq process.'
task :skk do
pid = File.open('./tmp/pids/sidekiq.pid') { |f| f.read }
system("kill #{pid.strip}")
puts 'Sidekiq killed.'
end
namespace :local do
desc "Start the application locally with Unicorn."
task :start do
system('source ~/.zshrc && bundle exec unicorn -c config/unicorn.rb -E production -D')
puts 'Unicorn started.'
end
desc "Stop the application runned with Unicorn."
task :stop do
pid = File.open('/home/onliner/current/tmp/pids/unicorn.pid') { |f| f.read }
system("kill #{pid.strip}")
puts 'Unicorn killed.'
end
end
namespace :remote do
desc 'Start the remote application with Capistrano.'
task :start do
system('bundle exec cap production app:start')
end
desc 'Stop the remote application with Capistrano.'
task :stop do
system('bundle exec cap production app:stop')
end
desc 'Start reparsing remotely with Capistrano.'
task :reparse do
system('bundle exec cap production app:reparse')
end
end