Class: Jets::Command::ServerCommand

Inherits:
Base
  • Object
show all
Includes:
EnvironmentArgument
Defined in:
lib/jets/commands/server/server_command.rb

Overview

:nodoc:

Constant Summary collapse

RACK_SERVERS =

Hard-coding a bunch of handlers here as we don’t have a public way of querying them from the Rack::Handler registry.

%w(cgi fastcgi webrick lsws scgi thin puma unicorn falcon)
DEFAULT_PORT =
8888
DEFAULT_PIDFILE =
"tmp/pids/server.pid"

Instance Method Summary collapse

Methods inherited from Base

base_name, command_name, default_command_root, desc, engine?, executable, exit_on_failure?, #help, hide_command!, inherited, long_desc, namespace, perform, printing_commands, usage_path

Methods included from ApiHelpers

#check_for_error_message!, #no_token_exit!, #paging_params

Methods included from AwsHelpers

#find_stack, #first_run?

Methods included from AwsServices

#apigateway, #aws_lambda, #aws_options, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Methods included from AwsServices::GlobalMemoist

included

Methods included from Actions

#load_generators, #load_tasks, #require_application!, #require_application_and_environment!, #set_application_directory!

Constructor Details

#initialize(args, local_options) ⇒ ServerCommand

Returns a new instance of ServerCommand.



124
125
126
127
128
# File 'lib/jets/commands/server/server_command.rb', line 124

def initialize(args, local_options, *)
  super

  @original_options = local_options - %w( --restart )
end

Instance Method Details

#performObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/jets/commands/server/server_command.rb', line 132

def perform
  extract_environment_option_from_argument
  set_application_directory!
  prepare_restart

  Jets::Server.new(server_options).tap do |server|
    # Require application after server sets environment to propagate
    # the --environment option.
    # require APP_PATH
    Jets.boot
    Dir.chdir(Jets.application.root)

    if server.serveable?
      print_boot_information(server.server, server.served_url)
      after_stop_callback = -> { say "Exiting" unless options[:daemon] }
      server.start(after_stop_callback)
    else
      say rack_server_suggestion(options[:using])
    end
  end
end