Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 43 lines (33 sloc) 1.49 KB
#!/usr/bin/env ruby
require 'optparse'
cur_location = File.dirname(__FILE__)
options = {:port => 3000, :environment => :production, :ply_root => cur_location, :daemonize => false}
OptionParser.new do |opts|
opts.banner = "Usage: ply [options]"
opts.on("-p", "--port PORT", Integer, "Web application port") do |p|
options[:port] = p
end
opts.on("-d", "--development", "Start in development mode") do |p|
options[:environment] = :development
end
opts.on("-r", "--ply_root ROOT", String, "Location of Ply boards") do |p|
options[:ply_root] = p
end
opts.on("-b", "--daemonize", "Run in background") do |p|
options[:daemonize] = p
end
end.parse!
puts "Starting ply with #{options}" if options[:environment].eql?(:development)
command = options[:environment].eql?(:production) ? "PLY_ROOT='#{options[:ply_root]}' rake -f #{cur_location}/Rakefile assets:precompile && " : ""
unless options[:ply_root].eql?(".")
command << "PLY_ROOT='#{options[:ply_root]}' "
end
if !(Gem::Specification.find_all_by_name("passenger").empty?)
command << "passenger start -p #{options[:port]} -e #{options[:environment].to_s} -R #{cur_location}/config.ru"
elsif !(Gem::Specification.find_all_by_name("passenger").empty?)
command << "thin start -p #{options[:port]} -R #{cur_location}/config.ru -e #{options[:environment].to_s}"
else
command << "rails s -p #{options[:port]} -c #{cur_location}/config.ru -e #{options[:environment].to_s}"
end
command << " -d" if options[:daemonize].eql?(true)
exec command
Something went wrong with that request. Please try again.