bin/rflow in rflow-1.3.1 vs bin/rflow in rflow-1.3.2
- old
+ new
@@ -84,10 +84,17 @@
#
# This logging setup will be used while we call into RFlow to check on or setup
# things, like the config database. We want those log messages to go to the
# startup log when setting up. The running log will transition to what is
# specified in the config database.
+if options[:startup_log_file_path] &&
+ File.exist?(options[:startup_log_file_path]) &&
+ !File.writable?(options[:startup_log_file_path])
+ STDERR.puts "Startup log file '#{options[:startup_log_file_path]}' not writable"
+ exit 1
+end
+
RFlow.logger.reconfigure({'rflow.application_name' => 'startup',
'rflow.log_level' => options[:startup_log_level].to_s,
'rflow.log_file_path' => options[:startup_log_file_path]}, true)
command = ARGV[0]
@@ -99,54 +106,62 @@
if options[:config_file_path] && command != 'load'
RFlow.logger.fatal "Config file only valid for 'load' command"
exit 1
end
+if !options[:config_file_path] && command == 'load'
+ RFlow.logger.fatal "Config file required for 'load' command"
+ exit 1
+end
+
unless options[:config_database_path]
RFlow.logger.warn "Config database not specified, using default 'config.sqlite'"
options[:config_database_path] = File.expand_path(File.join(Dir.getwd, 'config.sqlite'))
end
case command
when 'load'
# Load the database with the config file, if it exists. Will
# otherwise default values (not very useful)
- if options[:config_file_path]
- unless File.exist? options[:config_file_path]
- RFlow.logger.fatal "Config file '#{options[:config_file_path]}' not found\n#{option_parser.help}"
- exit 1
- end
- unless File.readable? options[:config_file_path]
- RFlow.logger.fatal "Config file '#{options[:config_file_path]}' not readable\n#{option_parser.help}"
- exit 1
- end
+ unless File.exist? options[:config_file_path]
+ RFlow.logger.fatal "Config file '#{options[:config_file_path]}' not found"
+ exit 1
end
- if File.exist? options[:config_database_path]
+ unless File.readable? options[:config_file_path]
+ RFlow.logger.fatal "Config file '#{options[:config_file_path]}' not readable"
+ exit 1
+ end
+
+ if File.exist?(options[:config_database_path]) && File.size(options[:config_database_path]) > 0
RFlow.logger.fatal "Config database '#{options[:config_database_path]}' exists, exiting to prevent accidental overwrite from config file '#{options[:config_file_path]}'"
exit 1
end
RFlow.logger.info "Creating config database '#{options[:config_database_path]}'"
begin
config = RFlow::Configuration::initialize_database(options[:config_database_path], options[:config_file_path])
rescue Exception => e
- RFlow.logger.fatal "Error initializing configuration database: #{e.message}: #{e.backtrace.join "\n"}"
+ RFlow.logger.fatal "Error initializing configuration database #{options[:config_database_path]}: #{e.message}: #{e.backtrace.join "\n"}"
exit 1
end
- RFlow.logger.warn "Successfully initialized database '#{options[:config_database_path]}' with '#{options[:config_file_path]}'"
+ RFlow.logger.info "Successfully initialized database '#{options[:config_database_path]}' with '#{options[:config_file_path]}'"
RFlow.logger.debug config.to_s
exit 0
end
# Load the database config and start setting up environment
begin
config = RFlow::Configuration.new(options[:config_database_path])
rescue Exception => e
- RFlow.logger.fatal "Error loading config database: #{e.class} - #{e.message}"
+ if e.is_a?(ArgumentError) && e.message =~ /Invalid schema in configuration database/
+ RFlow.logger.fatal "RFlow configuration database #{options[:config_database_path]} appears to be empty or missing. Perhaps you need to run 'rflow load -c <config file> -d #{options[:config_database_path]}'? (#{e.message})"
+ else
+ RFlow.logger.fatal "Error loading config database: #{e.class} - #{e.message}"
+ end
exit 1
end
Dir.chdir(File.dirname(options[:config_database_path]))
Dir.chdir(config['rflow.application_directory_path'])
@@ -189,16 +204,20 @@
# load all the file extensions
options[:extensions_file_paths].each do |extensions_file_path|
RFlow.logger.info "Loading #{extensions_file_path}"
unless File.readable? extensions_file_path
- RFlow.logger.fatal "Extensions file ('#{Dir.getwd}') '#{extensions_file_path}' not readable\n#{option_parser.help}"
+ RFlow.logger.fatal "Extensions file ('#{Dir.getwd}') '#{extensions_file_path}' not readable"
exit 1
end
begin
load extensions_file_path
rescue Exception => e
- RFlow.logger.fatal "Error running rflow: #{e.class}: #{e.message}, because: #{e.backtrace}"
+ if e.is_a?(ActiveRecord::RecordInvalid)
+ RFlow.logger.fatal "Error running rflow: It appears you may have passed a Ruby RFlow DSL file instead of an extensions file (which loads your application code) to rflow start -e #{extensions_file_path}. Please recheck your command arguments. (#{e.class}: #{e.message})"
+ else
+ RFlow.logger.fatal "Error running rflow: #{e.class}: #{e.message}, because: #{e.backtrace}"
+ end
exit 1
end
end
# Start the flow