-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
54 lines (47 loc) · 1.31 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
require 'rake'
require 'sequel'
require_relative 'src/app_config'
namespace :db do
desc "Run migrations"
task :migrate, [:version] do |t, args|
require "sequel"
config = AppConfig.instance
Sequel.extension :migration
if args[:version]
puts "Migrating to version #{args[:version]}"
Sequel::Migrator.run(config.db, "src/migrations", target: args[:version].to_i)
else
puts "Migrating to latest"
Sequel::Migrator.run(config.db, "src/migrations")
end
end
desc 'Populate the database with dummy data'
task 'populate' do
require 'securerandom'
config = AppConfig.instance
face_id = SecureRandom.uuid
Person.insert(
first_name: 'John',
last_name: 'Smith',
email: '[email protected]',
face_id: face_id
)
Event.insert(
face_id: face_id,
location: 'A',
timestamp: Time.now
)
end
end
# Run the server with shotgun for development
desc "Start the server for development"
task "run", [:port] do |t, args|
ENV['RACK_ENV'] = 'dev'
default_port = "9292"
host = "localhost"
port_arg = args.port
port = port_arg ? port_arg : default_port
puts "Start server: http://#{host}:#{port}/"
start_server_cmd = "bundle exec shotgun --server=thin --host=#{host} config.ru -p #{port}"
sh start_server_cmd
end