Sha256: 7e3c9a2e984344a971c4dfd03ed33530b3e4c7d7815d94c3805f81124dd00e54

Contents?: true

Size: 1.71 KB

Versions: 17

Compression:

Stored size: 1.71 KB

Contents

require "fluent/version"
require "zip"

class MiscController < ApplicationController
  after_action :update!, only: [:update_fluentd_ui]

  def show
    redirect_to misc_information_path
  end

  def information
    @env = ENV
    @plugins = Plugin.installed
  end

  def update_fluentd_ui
    @current_pid = $$
    render "update_fluentd_ui", layout: "sign_in"
  end

  def upgrading_status
    if FluentdUiRestart::LOCK.present?
      return render text: "updating"
    end

    if $$.to_s == params[:old_pid]
      # restarting fluentd-ui is finished, but PID doesn't changed.
      # maybe error occured at FluentdUiRestart#perform
      render text: "failed"
    else
      render text: "finished"
    end
  end

  def download_info
    fluentd = Fluentd.instance
    path = Rails.root.join("tmp/system_info.zip")
    File.unlink(path) if File.exists?(path)

    Zip::File.open(path, Zip::File::CREATE) do |zip|
      zip.get_output_stream('fluentd.log') {|f| f.puts fluentd.agent.log }
      if ENV["FLUENTD_UI_LOG_PATH"].present?
        zip.add("fluentd-ui.log", ENV["FLUENTD_UI_LOG_PATH"])
      else
        zip.add("fluentd-ui.log", Rails.root.join("log/#{Rails.env}.log"))
      end
      zip.get_output_stream('env.txt') do |f|
        ENV.to_a.each do |(key, value)|
          f.puts "#{key}=#{value}"
        end
      end
      zip.get_output_stream('versions.txt') do |f|
        f.puts "ruby: #{RUBY_DESCRIPTION}"
        f.puts "fluentd: #{FluentdUI.fluentd_version}"
        f.puts "fluentd-ui: #{FluentdUI::VERSION}"
        f.puts
        f.puts "# OS Information"
        f.puts "uname -a: #{`uname -a`.strip}"
      end
    end
    send_file path
  end

  private

  def update!
    FluentdUiRestart.new.async.perform
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fluentd-ui-0.3.11 app/controllers/misc_controller.rb
fluentd-ui-0.3.10 app/controllers/misc_controller.rb
fluentd-ui-0.3.9 app/controllers/misc_controller.rb
fluentd-ui-0.3.8 app/controllers/misc_controller.rb
fluentd-ui-0.3.7 app/controllers/misc_controller.rb
fluentd-ui-0.3.6 app/controllers/misc_controller.rb
fluentd-ui-0.3.5 app/controllers/misc_controller.rb
fluentd-ui-0.3.3 app/controllers/misc_controller.rb
fluentd-ui-0.3.2 app/controllers/misc_controller.rb
fluentd-ui-0.3.1 app/controllers/misc_controller.rb
fluentd-ui-0.3.0 app/controllers/misc_controller.rb
fluentd-ui-0.2.0 app/controllers/misc_controller.rb
fluentd-ui-0.1.4 app/controllers/misc_controller.rb
fluentd-ui-0.1.3 app/controllers/misc_controller.rb
fluentd-ui-0.1.2 app/controllers/misc_controller.rb
fluentd-ui-0.1.1 app/controllers/misc_controller.rb
fluentd-ui-0.1.0 app/controllers/misc_controller.rb