/
server.rb
48 lines (40 loc) · 1.52 KB
/
server.rb
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
# ===========================================================================
# Project: Abbot - SproutCore Build Tools
# Copyright: ©2009 Apple Inc.
# portions copyright @2006-2009 Sprout Systems, Inc.
# and contributors
# ===========================================================================
module SC
class Tools
desc "server", "Starts the development server"
method_options :daemonize => false,
:pid => :string,
:port => :string,
:host => :string,
:irb => false,
:filesystem => true
def server
prepare_mode!('debug') # set mode again, using debug as default
SC.env[:build_prefix] = options[:buildroot] if options[:buildroot]
SC.env[:staging_prefix] = options[:stageroot] if options[:stageroot]
# get project and start service.
project = requires_project!
# start shell if passed
if options[:irb]
require 'irb'
require 'irb/completion'
if File.exists? ".irbrc"
ENV['IRBRC'] = ".irbrc"
end
SC.project = project
SC.logger << "SproutCore v#{SC::VERSION} Interactive Shell\n"
SC.logger << "SC.project = #{project.project_root}\n"
ARGV.clear # do not pass onto IRB
IRB.start
else
SC.logger << "SproutCore v#{SC::VERSION} Development Server\n"
SC::Rack::Service.start(options.merge(:project => project))
end
end
end
end