From daf009b5b2be4d5e2e5782be0bfe79ad4bb31f03 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Wed, 25 Jul 2018 12:19:23 +0200 Subject: [PATCH] B #2318: Improve feedback for 'mode' option in Suntone server --- src/sunstone/models/SunstoneViews.rb | 8 ++++++++ src/sunstone/sunstone-server.rb | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sunstone/models/SunstoneViews.rb b/src/sunstone/models/SunstoneViews.rb index fc18813a95..92709b44f0 100644 --- a/src/sunstone/models/SunstoneViews.rb +++ b/src/sunstone/models/SunstoneViews.rb @@ -32,11 +32,19 @@ class SunstoneViews VIEWS_CONFIGURATION_DIR = ETC_LOCATION + "/sunstone-views/" def initialize(mode) + + raise "Sunstone configuration file does not contain default view mode, aborting" if mode.nil? + @views_config = YAML.load_file(VIEWS_CONFIGURATION_FILE) base_path = SUNSTONE_ROOT_DIR+'/public/js/' @views = Hash.new + + raise "The #{mode} view directory does not exists, aborting" if Dir[VIEWS_CONFIGURATION_DIR + mode].empty? + + raise "The #{mode} view directory is empty, aborting" if Dir[VIEWS_CONFIGURATION_DIR + mode + '/*.yaml'].empty? + Dir[VIEWS_CONFIGURATION_DIR + mode + '/*.yaml'].each do |p_path| reg = VIEWS_CONFIGURATION_DIR + mode + '/' m = p_path.match(/^#{reg}(.*).yaml$/) diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 12189c1643..7e18f752fc 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -183,7 +183,12 @@ end set :cloud_auth, $cloud_auth -$views_config = SunstoneViews.new($conf[:mode]) +begin + $views_config = SunstoneViews.new($conf[:mode]) +rescue StandardError => e + logger.error { e.message } + exit -1 +end #start VNC proxy