forked from saurabh/orbit4-5
update orbit_cron rake
This commit is contained in:
parent
e39fac0579
commit
902ebfc775
|
@ -1,36 +1,11 @@
|
|||
namespace :orbit_cron do
|
||||
task :install => :environment do
|
||||
|
||||
# Setup environment in crontab
|
||||
cron_env ="#!/bin/bash\n"+
|
||||
"PATH=#{ENV['PATH']}\n"+
|
||||
"RUBYLIB=#{ENV['RUBYLIB']}\n"+
|
||||
"GEM_HOME=#{ENV['GEM_HOME']}\n"+
|
||||
"GEM_PATH=#{ENV['GEM_PATH']}\n"+
|
||||
"RUBYOPT=#{ENV['RUBYOPT']}\n\n"
|
||||
|
||||
# Email cron job
|
||||
email_cron = "* * * * * cd #{Rails.root.to_s} && bundle exec rake email:deliver_all > /dev/null\n"
|
||||
email_cron="* * * * * /bin/bash -l -c 'source \"$HOME/.rvm/scripts/rvm\" && rvm use default && cd #{Rails.root.to_s} && bundle exec rake email:deliver_all > /dev/null'"
|
||||
|
||||
File.open('lib/tasks/orbit_cron', "w+") do |f|
|
||||
f.write(cron_env + email_cron)
|
||||
end
|
||||
%x(CRON="#{email_cron}" && (crontab -l; echo "$CRON" ) | crontab -)
|
||||
|
||||
# Check if current crontab is empty
|
||||
if %x(crontab -l).eql? ""
|
||||
%x(crontab #{Rails.root.to_s+'/lib/tasks/orbit_cron'})
|
||||
%x(rm #{Rails.root.to_s+'/lib/tasks/orbit_cron'})
|
||||
puts "\n"
|
||||
puts "Orbit cron jobs installed\n"
|
||||
else
|
||||
puts "\n"
|
||||
puts "============================ Warning! ============================\n"
|
||||
puts "Crontab is not empty!\n"
|
||||
puts "Please edit crontab with command 'crontab -e' and paste the following lines:\n"
|
||||
puts "=================================================================\n"
|
||||
puts cron_env + email_cron
|
||||
puts "=================================================================\n"
|
||||
puts "\n\n"
|
||||
end
|
||||
puts "Cron jobs installed\n"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue