announcement-test/temp_file/config/do_on_startup.rb

85 lines
2.3 KiB
Ruby

OrbitApp.cleanup_modules
begin
OrbitApp.check_module_permissions
rescue Exception => e
end
include BundlerHelper
site = Site.first
if (site.password_failed_lock_num.nil? rescue false)
site.update({:password_failed_lock_num=> site.fields['password_failed_lock_num'].options[:default]})
end
site.update(:valid_locales=>I18n.available_locales)
site.reset_cache
if ModuleApp.where(:key=>'member_sign_up').count > 1
ModuleApp.where(:key=>'member_sign_up')[0...1].each{|m| m.destroy}
end
if (site.page_sets.count==0 rescue false)
site.page_sets.create()
elsif site.page_sets.count > 1
site.page_sets.skip(1).destroy
end
begin
require File.expand_path('../do_on_startup_helper', __FILE__)
load_error = false
rescue LoadError
load_error = true
end
if File.basename($0) != 'rake' && !load_error
fix_email_job
fix_site_root_url(site)
if ShowForAdminMessage.first.nil?
ShowForAdminMessage.create()
end
if site.template.nil?
site.template = (Dir.glob("#{Rails.root}/app/templates/*").collect{|temp| temp.split('/').last}-['mobile']).first
site.save
end
require File.expand_path('../initial_site_data', __FILE__)
MemberProfileDefaultField.get_field_to_set
MemberIndexCache.all.delete_all
env_pwd = ENV['PWD']
dir_name = env_pwd.split('/')[-1]
fix_css_file
fix_template_header_file
fix_datatable_width_issue
watch_dog = %x[screen -ls auto_reopen_#{dir_name}]
if watch_dog.scan("auto_reopen_#{dir_name}").count != 0
bundler_with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]}
end
if !Rails.const_defined?('Console')
Thread.new do
begin
fix_script_permission
fix_page_part
fix_broken_page
# Site.make_cache
fix_empty_user
fix_old_content_unit(site)
fix_member_info_cache(site)
fix_db_index
fix_asset_data(site)
fix_user_password_notify(site)
fix_site_map(site)
fix_login_page(site)
fix_sort_number(site)
fix_thumb(site)
fix_selection_option(site)
fix_member_profile_field(site)
fix_member_page_cache(site)
fix_module_app(site)
fix_impression_count(site)
if ChecklistMainSetting.count == 0
ChecklistMainSetting.create
end
rescue => e
puts [e,e.backtrace]
end
end
end
end