Class: Geb::CLI::Commands::Server
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Geb::CLI::Commands::Server
- Defined in:
- lib/geb/commands/server.rb
Overview
Define server command
Instance Method Summary collapse
-
#call(**options) ⇒ Object
Call method for the server command.
-
#force_shutdown ⇒ Object
Force shutdown of the server.
Instance Method Details
#call(**options) ⇒ Object
Call method for the server command
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/geb/commands/server.rb', line 33 def call(**) # initialise a site and load it from the current directory site = Geb::Site.new site.load(Dir.pwd) # build the site if the skip_build option is not set site.build() unless [:skip_build] # start a new queue for the shutdown signal (instead of using trap to shutdown the server and file watcher directly) @shutdown_queue = Queue.new trap('INT') { @shutdown_queue << :shutdown } # get the server port from the options, site configuration or auto generated (0), in that order server_port = [:port] || site.site_config.local_port || 0 # initialize the server server = Geb::Server.new(site, server_port, ![:skip_auto_build], [:debug]) # start the server server.start() # wait for the shutdown signal @shutdown_queue.pop # stop the server server.stop() rescue Geb::Error => e # print error message puts warn e. end |
#force_shutdown ⇒ Object
Force shutdown of the server
70 71 72 |
# File 'lib/geb/commands/server.rb', line 70 def force_shutdown @shutdown_queue << :shutdown if @shutdown_queue end |