Class: Locomotive::Wagon::ServeCommand
- Inherits:
-
Struct
- Object
- Struct
- Locomotive::Wagon::ServeCommand
- Defined in:
- lib/locomotive/wagon/commands/serve_command.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#shell ⇒ Object
Returns the value of attribute shell.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, options, shell) ⇒ ServeCommand
constructor
A new instance of ServeCommand.
- #start ⇒ Object
- #stop(force = false) ⇒ Object
Constructor Details
#initialize(path, options, shell) ⇒ ServeCommand
Returns a new instance of ServeCommand.
7 8 9 10 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 7 def initialize(path, , shell) super(path, || {}, shell) @parent_id = nil end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options
5 6 7 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 5 def @options end |
#path ⇒ Object
Returns the value of attribute path
5 6 7 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 5 def path @path end |
#shell ⇒ Object
Returns the value of attribute shell
5 6 7 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 5 def shell @shell end |
Class Method Details
.start(path, options = {}, shell) ⇒ Object
12 13 14 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 12 def self.start(path, = {}, shell) new(path, , shell).start end |
.stop(path, force = false, shell) ⇒ Object
16 17 18 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 16 def self.stop(path, force = false, shell) new(path, nil, shell).stop(force) end |
Instance Method Details
#start ⇒ Object
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 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 20 def start # make sure a server is not running stop(true) if [:force] # Steam is our rendering engine require_steam # in case the developer installed custom libs Locomotive::Wagon.require_misc_gems setup_signals show_rack_middleware_stack if [:debug] # if a page, a content type or any resources of the site is getting modified, # then the cache of Steam will be cleared. listen # let's start! begin server.start rescue NoMethodError # Prevent the NilClass error from Puma to be displayed nil end end |
#stop(force = false) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/locomotive/wagon/commands/serve_command.rb', line 48 def stop(force = false) unless File.exist?(server_pid_file) shell.say "No Wagon server is running.", :red return end pid = File.read(server_pid_file).to_i Process.kill('TERM', pid) shell.say "\nShutting down Wagon server" # make sure we wait enough for the server process to stop sleep(2) if force end |