blob: 553955d1147be686d383c25a79c21a28c82b47bd [file] [log] [blame]
# standalone roster server
task :server => [:bundle, :listen] do
ENV['RACK_ENV']='development'
at_exit {sleep 0.5}
sh 'bundle exec passenger start'
end
file 'Gemfile.lock' => 'Gemfile' do
sh 'bundle update'
touch 'Gemfile.lock'
end
# setup authentication
task :auth do
require 'etc'
require 'io/console'
require 'base64'
user = ENV['USER'] || ETC.getlogin
STDOUT.write "Enter password for #{user}: "
password = STDIN.noecho(&:gets).chomp
ENV['HTTP_AUTHORIZATION'] = "Basic #{Base64.encode64("#{user}:#{password}")}"
STDOUT.puts
end
desc 'install dependencies'
task :bundle => 'Gemfile.lock' do
require 'bundler'
Bundler.require(:default, :development)
end
# restart server when files update
task :listen => :bundle do
dirs = [
File.expand_path('..', File.realpath(__FILE__)),
File.expand_path('../../../lib', File.realpath(__FILE__))
]
listener = Listen.to(*dirs) do |modified, added, removed|
puts "detected update: #{(modified + added + removed).join(', ')}"
FileUtils.touch "#{dirs.first}/tmp/restart.txt"
end
listener.ignore /~$/
listener.ignore /^\..*\.sw\w$/
listener.ignore /passenger.\d+\.(log|pid(\.lock)?)$/
listener.start
end