-
Notifications
You must be signed in to change notification settings - Fork 6
/
play
executable file
·49 lines (36 loc) · 1.08 KB
/
play
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
#!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'play'
require 'optparse'
parser = OptionParser.new do |opts|
opts.banner = "Usage: play [options] COMMAND"
opts.separator ""
opts.separator "Options:"
opts.on("--migrate", "Setup the database") do
ActiveRecord::Base.establish_connection(Play.config['db'])
ActiveRecord::Migrator.migrate("#{File.dirname(__FILE__)}/db/migrate")
end
opts.on("-d", "--detach", "Start the music server") do
ENV['RACK_ENV'] = 'production'
pid = fork { Play::Client.loop }
Process.detach(pid)
end
opts.on("-s", "--stop", "Stop the music server") do
Play::Client.stop
end
opts.on("-w", "--web", "Run the web instance") do
system("rackup -p 5050 #{File.dirname(__FILE__)}/../config.ru")
end
opts.on("-p", "--path", "Pause the music server") do |path|
Play::Client.pause
end
opts.on("-i", "--import", "Import new songs") do |import|
Play::Library.import_songs
exit
end
opts.on("-h", "--help", "Show this message") do
puts opts
exit
end
end
parser.parse!