Sha256: 1d753fdf73c60b4110cdfb39e5e9d9a2f14f32b63bebe87a2b7f7c1bf95e2d5b

Contents?: true

Size: 1.19 KB

Versions: 21

Compression:

Stored size: 1.19 KB

Contents

require "grape"
require "get_process_mem"

module RestFtpDaemon
  module API
    class Status < Grape::API
      include BmcDaemonLib

      ### HELPERS
      helpers do
        def log_context
          {caller: "API::Status"}
        end
      end

      ### ENDPOINTS
      desc "Show daemon status"
      get "/" do
        status 200

        # Get counters
        counters = RestFtpDaemon::Counters.instance.stats

        # Amend counters with legacy attributes
        if counters[:jobs].is_a? Hash
          counters[:jobs_finished] = counters[:jobs][:finished] || 0
          counters[:jobs_failed]   = counters[:jobs][:failed] || 0
        end
        if counters[:data].is_a? Hash
          counters[:transferred] = counters[:data][:transferred] || 0
        end

        # Generate sutrcture
        return  {
          name: Conf.app_name,
          version: Conf.app_ver,
          started: Conf.app_started,
          hostname: `hostname`.to_s.chomp,
          jobs_count: RestFtpDaemon::JobQueue.instance.jobs_count,

          metrics: Metrics.sample,

          counters: counters,

          workers: RestFtpDaemon::WorkerPool.instance.worker_variables,

          }
      end

    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rest-ftp-daemon-1.1.1 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.1.0 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.15 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.14 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.13 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.12 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.11 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.10 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.9 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.8 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.7 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.6 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.5 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.4 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.3 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.2 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-1.0.1 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-0.502.2 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-0.502.1 lib/rest-ftp-daemon/api/status.rb
rest-ftp-daemon-0.502.0 lib/rest-ftp-daemon/api/status.rb