Add Sidetiq webview to the Sidekiq monitoring panel Add rake task maintenance:queue_users_for_removal This basically just triggers an immediate run of the normal maintenance remove old users functionality that is normally (if enabled) scheduled to run once a day via sidetiq Add extra safety when checking for user removal due to inactivity. Now also user.last_seen will also be checked to make sure a user will not be removed in the event that the Devise rememember me login functionality has stopped the users remove_after timestamp from being removed. Add initializer for maintenance job. Add warning about mail being disabled if remove_old_users maintenance is enabled.
48 lines
1.4 KiB
Ruby
48 lines
1.4 KiB
Ruby
# Copyright (c) 2011, Diaspora Inc. This file is
|
|
# licensed under the Affero General Public License version 3 or later. See
|
|
# the COPYRIGHT file.
|
|
|
|
namespace :maintenance do
|
|
APP_ROOT = File.expand_path( File.join( File.dirname( __FILE__ ), '..', '..') )
|
|
desc "Clear CarrierWave temp uploads"
|
|
task :clear_carrierwave_temp_uploads do
|
|
filename = File.join( APP_ROOT, 'tmp', 'uploads', '*')
|
|
today_string = Time.now.strftime( '%Y%m%d' )
|
|
Dir.glob( filename ) do |file|
|
|
unless file.include?( today_string )
|
|
FileUtils.rm_rf( file )
|
|
end
|
|
end
|
|
end
|
|
|
|
desc "Rotate Diaspora logs"
|
|
task :install_logrotate_config do
|
|
logrotate_conf = <<-RUBY
|
|
#{APP_ROOT}/logs/production.log {
|
|
daily
|
|
missingok
|
|
rotate 8
|
|
compress
|
|
delaycompress
|
|
notifempty
|
|
copytruncate
|
|
}
|
|
RUBY
|
|
begin
|
|
File.open('/etc/logrotate.d/diaspora') do |fin|
|
|
fin.write logrotate_conf
|
|
end
|
|
rescue
|
|
puts "Could not install logrotate configs. Perhaps you should try running this task as root and ensuring logrotate is installed:\n#{logrotate_conf}"
|
|
end
|
|
end
|
|
|
|
desc "Queue users for removal"
|
|
task :queue_users_for_removal => :environment do
|
|
# Queue users for removal due to inactivity
|
|
# Note! settings.maintenance.remove_old_users
|
|
# must still be enabled, this only bypasses
|
|
# scheduling to run the queuing immediately
|
|
Workers::QueueUsersForRemoval.perform_async
|
|
end
|
|
end
|