From bb306364aaa0f0c6c4fe0956153bace87d4682e3 Mon Sep 17 00:00:00 2001 From: manson Date: Thu, 26 Jun 2014 11:15:41 +0800 Subject: [PATCH] Removed omniauth and update dashboard disk usage for Ubuntu 14.04 --- .../admin/dashboards_controller.rb | 3 +- .../admin/omniauth_callbacks_controller.rb | 10 ---- config/resque_schedule.yml | 4 +- config/solr.god | 57 ------------------- lib/omniauth/strategies/doorkeeper.rb | 26 --------- 5 files changed, 3 insertions(+), 97 deletions(-) delete mode 100644 app/controllers/admin/omniauth_callbacks_controller.rb delete mode 100644 config/solr.god delete mode 100644 lib/omniauth/strategies/doorkeeper.rb diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index e7fd745..102ed76 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -46,8 +46,7 @@ class Admin::DashboardsController < OrbitBackendController end def get_disk_usage - @usw = Usagewatch - render :json => @usw.uw_diskused_perc.to_s + render :json => `df -m /home`.scan(/\d+%/).first.gsub('%','') rescue '0' end def get_month_traffic diff --git a/app/controllers/admin/omniauth_callbacks_controller.rb b/app/controllers/admin/omniauth_callbacks_controller.rb deleted file mode 100644 index f034740..0000000 --- a/app/controllers/admin/omniauth_callbacks_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController - def doorkeeper - oauth_data = request.env["omniauth.auth"] - @user = User.find_or_create_for_doorkeeper_oauth(oauth_data) - @user.update_doorkeeper_credentials(oauth_data) - @user.save - - sign_in_and_redirect @user - end -end \ No newline at end of file diff --git a/config/resque_schedule.yml b/config/resque_schedule.yml index d6a7e83..1d2984f 100644 --- a/config/resque_schedule.yml +++ b/config/resque_schedule.yml @@ -1,5 +1,5 @@ update_tag_cloud: - cron: 0 0 [0,12] * * * + cron: 0 0 0,12 * * * class: UpdateTagCloud args: description: UpdateTagCloud @@ -11,7 +11,7 @@ generate_system_summary: description: Generate the system status such as disk free space,package version list for showing at site tab email_cron: - cron: 0 0 [10,14,17,20] * * * + cron: 0 0 10,14,17,20 * * * class: EmailCron args: description: EmailCron diff --git a/config/solr.god b/config/solr.god deleted file mode 100644 index 10bb2e3..0000000 --- a/config/solr.god +++ /dev/null @@ -1,57 +0,0 @@ -rails_env = ENV['RAILS_ENV'] || "production" -rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/..' -user_home = ENV['HOME'] || File.dirname(__FILE__) + '/../..' -development_uid = '' -development_gid = '' - - God.watch do |w| - w.dir = rails_root - w.name = "sunspot-solr" - w.group = 'rulingcom' - w.interval = 30.seconds - w.env = {"RAILS_ENV"=>rails_env} - w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile sunspot:solr:start" - w.keepalive - w.uid = (rails_env == 'production' )? "root" : development_uid - w.gid = (rails_env == 'production' )? "root" : development_gid - w.pid_file = "#{rails_root}/solr/pids/production/sunspot-solr-production.pid" - w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log" - - # restart if memory gets too high - w.transition(:up, :restart) do |on| - on.condition(:memory_usage) do |c| - c.above = 350.megabytes - c.times = 2 - end - end - - # determine the state on startup - w.transition(:init, { true => :up, false => :start }) do |on| - on.condition(:process_running) do |c| - c.running = true - end - end - - # determine when process has finished starting - w.transition([:start, :restart], :up) do |on| - on.condition(:process_running) do |c| - c.running = true - c.interval = 5.seconds - end - - # failsafe - on.condition(:tries) do |c| - c.times = 5 - c.transition = :start - c.interval = 5.seconds - end - end - - # start if process is not running - w.transition(:up, :start) do |on| - on.condition(:process_running) do |c| - c.running = false - end - end - end - diff --git a/lib/omniauth/strategies/doorkeeper.rb b/lib/omniauth/strategies/doorkeeper.rb deleted file mode 100644 index 16bdb93..0000000 --- a/lib/omniauth/strategies/doorkeeper.rb +++ /dev/null @@ -1,26 +0,0 @@ -module OmniAuth - module Strategies - class Doorkeeper < OmniAuth::Strategies::OAuth2 - option :name, :doorkeeper - - option :client_options, { - :site => "http://localhost:8000", - :authorize_path => "/oauth/authorize" - } - - uid do - raw_info["id"] - end - - info do - { - :email => raw_info["email"] - } - end - - def raw_info - @raw_info ||= access_token.get('/api/v1/me.json').parsed - end - end - end -end \ No newline at end of file