From 934edc5f81ca72711f0db006ee213ee93747019a Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 8 Dec 2014 18:11:10 +0800 Subject: [PATCH] removes uninstalled modules and also attemp to bundle install fast --- app/controllers/admin/sites_controller.rb | 5 +++-- config/environment.rb | 2 +- lib/orbit_app/register_module.rb | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 38da321..87175db 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -105,7 +105,8 @@ class Admin::SitesController < OrbitAdminController result = "failed" else result = "success" - Bundler.with_clean_env { `cd #{Rails.root} && bundle update` } + # Bundler.with_clean_env { `cd #{Rails.root} && bundle update` } + Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=built_in_extensions.rb bundle update && bundle` } end render :text => result @@ -115,7 +116,7 @@ class Admin::SitesController < OrbitAdminController end def bundle_install - Bundler.with_clean_env { `cd #{Rails.root} && bundle update` } + Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=built_in_extensions.rb bundle update && bundle` } %x(kill -s USR2 `cat tmp/pids/unicorn.pid`) sleep 5 render :nothing => true diff --git a/config/environment.rb b/config/environment.rb index 8cb62bd..a176bdd 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -4,7 +4,7 @@ require File.expand_path('../application', __FILE__) # Initialize the Rails application. Orbit::Application.initialize! Orbit::Application.config.secret_key_base = 'acc6ffc5a7d360c9cf2a7bdb4ddf9a897942ec6767413a5c0324a0fa8b86197a96298288a66bd46d8770d8b6edf509aad65716961c2c364ce006b475e6cfd418' - +OrbitApp.cleanup_modules if Site.count == 0 site = Site.new diff --git a/lib/orbit_app/register_module.rb b/lib/orbit_app/register_module.rb index 3d40222..44797d7 100644 --- a/lib/orbit_app/register_module.rb +++ b/lib/orbit_app/register_module.rb @@ -10,5 +10,15 @@ module OrbitApp Widget::Registration.new(name,&block) end end + + def cleanup_modules + module_apps = ModuleApp.all + module_apps.each do |ma| + reg = OrbitApp::Module::Registration.find_by_key(ma.key) rescue nil + if reg.nil? + ma.destroy + end + end + end end end \ No newline at end of file