Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 54 lines (42 sloc) 1.63 KB
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'radiodan'
require 'fileutils'
$: << './lib'
require 'web_app'
require 'radio_station'
require 'middleware/faye_relay'
require 'middleware/radio_controller'
require 'middleware/preference'
require 'middleware/faye_web_server'
require 'middleware/track_avoider'
require 'middleware/programme_avoider'
preferences_file_path = './db/prefs.yml'
root = File.join(File.dirname(__FILE__), '..')
# Correctly exit when SIGTERM is received
%w{INT TERM SIGHUP SIGINT SIGTERM}.each do |signal|
Signal.trap(signal) do
exit
end
end
avoiding_filename = 'birdsong.mp3'
# Copy avoider track sound into place
from_path = File.absolute_path(File.join(root, 'sounds', avoiding_filename))
to_path = File.join('/music', avoiding_filename)
FileUtils.cp(from_path, to_path, :verbose => true) unless File.exists?(to_path)
FileUtils.chmod(0777, to_path)
bbc_stations = RadioStation.list
puts "bbc_stations #{bbc_stations}"
WebApp.stations = bbc_stations
radio = Radiodan.new do |builder|
builder.log STDOUT
builder.adapter :MPD, :host => 'localhost', :port => 6600
builder.use :faye_web_server, WebApp, :port => 3000
builder.use :faye_relay, :port => 3000
builder.use :radio_controller, :stations => bbc_stations
builder.use :preference, :file_path => preferences_file_path, :playlist => RadioController.playlist, :stations => bbc_stations
builder.use :track_avoider, :avoiding_track => Radiodan::Track.new(:file => avoiding_filename)
builder.use :programme_avoider, :avoiding_track => Radiodan::Track.new(:file => avoiding_filename)
end
radio.start