From bc6b82512856d88f7e0bebd4f31fab38ec129b83 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Fri, 31 May 2013 09:59:45 -0700 Subject: [PATCH] Error out early if there is no app configured --- lib/puma/cli.rb | 10 ++++++++++ lib/puma/configuration.rb | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/puma/cli.rb b/lib/puma/cli.rb index e0f70892..e0f5d5e9 100644 --- a/lib/puma/cli.rb +++ b/lib/puma/cli.rb @@ -419,6 +419,11 @@ module Puma @binder.parse @options[:binds], self + unless @config.app_configured? + error "No application configured, nothing to run" + exit 1 + end + if @options[:daemon] Process.daemon(true, @io_redirected) end @@ -651,6 +656,11 @@ module Puma @binder.parse @options[:binds], self + unless @config.app_configured? + error "No application configured, nothing to run" + exit 1 + end + read, write = Puma::Util.pipe Signal.trap "SIGCHLD" do diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index 3d14cafd..418f3b10 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -67,6 +67,17 @@ module Puma end end + # Indicate if there is a properly configured app + # + def app_configured? + return true if @options[:app] + if path = @options[:rackup] + return File.exists?(path) + end + + false + end + # Load the specified rackup file, pull an options from # the rackup file, and set @app. #