lib/cli/commands/apps.rb in vmc-0.3.16.beta.3 vs lib/cli/commands/apps.rb in vmc-0.3.16.beta.5

- old
+ new

@@ -191,11 +191,11 @@ def files(appname, path='/') return all_files(appname, path) if @options[:all] && !@options[:instance] instance = @options[:instance] || '0' content = client.app_files(appname, path, instance) display content - rescue VMC::Client::TargetError + rescue VMC::Client::NotFound, VMC::Client::TargetError err 'No such file or directory' end def logs(appname) # Check if we have an app before progressing further @@ -673,51 +673,50 @@ end display '' end end - def log_file_paths - %w[logs/stderr.log logs/stdout.log logs/startup.log] - end - def grab_all_logs(appname) instances_info_envelope = client.app_instances(appname) return if instances_info_envelope.is_a?(Array) instances_info = instances_info_envelope[:instances] || [] instances_info.each do |entry| grab_logs(appname, entry[:index]) end end def grab_logs(appname, instance) - log_file_paths.each do |path| + files_under(appname, instance, "/logs").each do |path| begin content = client.app_files(appname, path, instance) display_logfile(path, content, instance) - rescue VMC::Client::TargetError + rescue VMC::Client::NotFound, VMC::Client::TargetError end end end + def files_under(appname, instance, path) + client.app_files(appname, path, instance).split("\n").collect do |l| + "#{path}/#{l.split[0]}" + end + rescue VMC::Client::NotFound, VMC::Client::TargetError + [] + end + def grab_crash_logs(appname, instance, was_staged=false) # stage crash info crashes(appname, false) unless was_staged instance ||= '0' map = VMC::Cli::Config.instances instance = map[instance] if map[instance] - %w{ - /logs/err.log /logs/staging.log /logs/migration.log - /app/logs/stderr.log /app/logs/stdout.log /app/logs/startup.log - /app/logs/migration.log - }.each do |path| - begin - content = client.app_files(appname, path, instance) - display_logfile(path, content, instance) - rescue VMC::Client::TargetError - end + (files_under(appname, instance, "/logs") + + files_under(appname, instance, "/app/logs") + + files_under(appname, instance, "/app/log")).each do |path| + content = client.app_files(appname, path, instance) + display_logfile(path, content, instance) end end def grab_startup_tail(appname, since = 0) new_lines = 0 @@ -730,11 +729,11 @@ tail = response_lines[since, lines] || [] new_lines = tail.size display tail.join("\n") if new_lines > 0 end since + new_lines - rescue VMC::Client::TargetError + rescue VMC::Client::NotFound, VMC::Client::TargetError 0 end def provisioned_services_apps_hash apps = client.apps @@ -1062,10 +1061,10 @@ path, content, entry[:index], "====> [#{entry[:index]}: #{path}] <====\n".bold ) - rescue VMC::Client::TargetError + rescue VMC::Client::NotFound, VMC::Client::TargetError end end end end