-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
56 lines (48 loc) · 1.39 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
require 'timeout'
require 'sinatra/activerecord/rake'
namespace :db do
task :load_config do
require_relative 'models/author'
require_relative 'models/book'
end
desc "Blocks until connection to database is available"
task :ready do
begin
require 'sinatra/activerecord'
rescue Mysql2::Error, Timeout::Error => e
STDERR.puts "waiting for database"
STDERR.flush
sleep 1
retry
end
STDERR.puts "database ready"
end
end
namespace :dev do
desc "Starts the webapp app in development mode on port 7000"
task webapp: "db:ready" do
sh "bundle exec ruby webapp.rb -p 7000"
end
desc "Starts the authors app in development mode on port 7001"
task authors: "db:ready" do
sh "bundle exec ruby authors.rb -p 7001"
end
desc "Starts the books app in development mode on port 7002"
task books: "db:ready" do
sh "bundle exec ruby books.rb -p 7002"
end
end
namespace :prod do
desc "Starts the webapp app in production mode on port 7000"
task webapp: "db:ready" do
sh "bundle exec ruby webapp.rb -e production -p 7000"
end
desc "Starts the authors app in production mode on port 7001"
task authors: "db:ready" do
sh "bundle exec ruby authors.rb -e production -p 7001"
end
desc "Starts the books app in production mode on port 7002"
task books: "db:ready" do
sh "bundle exec ruby books.rb -e production -p 7002"
end
end