def run
parse_options
load_local_config_file
load_env_config
remerge_all_options
sanity_check_options_and_set_defaults
lookup_runtime_and_ensure_installed
set_stdout_stderr_binmode
exit if @options[:runtime_check_only]
find_apps
find_pid_and_log_file(@app_finder, @options)
create_working_dir
initialize_vars
start_engine
begin
show_intro_message
maybe_daemonize
touch_temp_dir_in_background
watch_log_files_in_background if should_watch_logs?
wait_until_engine_has_exited if should_wait_until_engine_has_exited?
rescue Interrupt
trapsafe_shutdown_and_cleanup(true)
exit 2
rescue SignalException => signal
trapsafe_shutdown_and_cleanup(true)
if signal.message == 'SIGINT' || signal.message == 'SIGTERM'
exit 2
else
raise
end
rescue Exception
trapsafe_shutdown_and_cleanup(true)
raise
else
trapsafe_shutdown_and_cleanup(false)
ensure
reset_traps_intterm
end
end