1namespace :epets do |
|
2 desc "Add sysadmin user" |
|
3 task :add_sysadmin_user => :environment do |
|
4 if AdminUser.find_by(email: 'admin@example.com').nil? |
|
5 admin = AdminUser.new(:first_name => 'Cool', :last_name => 'Admin', :email => 'admin@example.com') |
|
6 admin.role = 'sysadmin' |
|
7 admin.password = admin.password_confirmation = 'Letmein1!' |
|
8 admin.save!
|
|
9 end |
|
10 end |
|
12 desc "Email threshold users with a list of threshold petitions" |
|
13 task :threshold_email_reminder => :environment do |
|
14 Task.run("epets:threshold_email_reminder") do |
|
15 EmailThresholdReminderJob.perform_later |
|
16 end |
|
17 end |
|
19 desc "Special resend of signature email validation" |
|
20 task :special_resend_of_signature_email_validation => :environment do |
|
21 EmailReminder.special_resend_of_signature_email_validation |
|
22 end |
|
24 namespace :whenever do |
|
25 desc "Update the Primary Server crontab" |
|
26 task :update_crontab_primary => :environment do |
|
27 Whenever::CommandLine.execute( |
|
28 :update => true, |
|
29 :set => "environment=#{RAILS_ENV}", |
|
30 :identifier => 'Epets_primary_server' |
|
31 )
|
|
32 end |
|
34 desc "Update the all servers crontab" |
|
35 task :update_crontab_all => :environment do |
|
36 Whenever::CommandLine.execute( |
|
37 :update => true, |
|
38 :set => "environment=#{RAILS_ENV}", |
|
39 :identifier => 'Epets_all_servers', |
|
40 :file => 'config/schedule_all_servers.rb' |
|
41 )
|
|
42 end |
|
43 end |
|
45 namespace :jobs do |
|
46 desc "Unlock all delayed jobs (to be used after a restart)" |
|
47 task :unlock_all => :environment do |
|
48 Delayed::Job.update_all("locked_by = NULL, locked_at = NULL") |
|
49 end |
|
50 end |
|
52 namespace :site do |
|
53 desc "Enable the website" |
|
54 task :enable => :environment do |
|
55 Site.instance.update! enabled: true |
|
56 end |
|
58 desc "Disable the website" |
|
59 task :disable => :environment do |
|
60 Site.instance.update! enabled: false |
|
61 end |
|
63 desc "Protect the website" |
|
64 task :protect => :environment do |
|
65 Site.instance.update! protected: true, username: ENV.fetch('SITE_USERNAME'), password: ENV.fetch('SITE_PASSWORD') |
|
66 end |
|
68 desc "Unprotect the website" |
|
69 task :unprotect => :environment do |
|
70 Site.instance.update! protected: false |
|
71 end |
|
73 desc "Start the signature count updater if it's not running" |
|
74 task :signature_counts => :environment do |
|
75 Task.run("epets:site:signature_counts", 10.minutes) do |
|
76 break unless Site.update_signature_counts |
|
78 unless Site.signature_count_updated_at > 15.minutes.ago |
|
79 UpdateSignatureCountsJob.perform_later |
|
80 end |
|
81 end |
|
82 end |
|
84 desc "Track trending domains" |
|
85 task :trending_domains => :environment do |
|
86 Task.run("epets:site:trending_domains", 30.minutes) do |
|
87 TrendingDomainsByPetitionJob.perform_later |
|
88 end |
|
89 end |
|
91 desc "Track trending IP addresses" |
|
92 task :trending_ips => :environment do |
|
93 Task.run("epets:site:trending_ips", 30.minutes) do |
|
94 TrendingIpsByPetitionJob.perform_later |
|
95 end |
|
96 end |
|
97 end |
|
99 namespace :cache do |
|
100 desc "Clear the cache" |
|
101 task :clear => :environment do |
|
102 Rails.cache.clear |
|
103 end |
|
104 end |
|
105end |