-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrake_task_runner
executable file
·104 lines (82 loc) · 4.3 KB
/
rake_task_runner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
export RAILS_ENV=$1
# needs to find ruby and rake binaries
if [ "$1" == "production" ]; then
echo $PATH
# export PATH=$PATH:/usr/local/rvm/gems/ruby-2.4.2@sac-platform-rails4/bin:/usr/local/rvm/gems/ruby-2.4.2@sac-platform-rails4/bin:/usr/local/rvm/rubies/ruby-2.4.2/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin
# [[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" && rvm use ruby-2.4.2@global
else
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" && rvm use ruby-2.4.2@global
fi
# 15 0 * * * rake_task_runner
LOGFILE="/app/log/cron_rake.log"
echo "`date` env variable => `env`"
echo "`date` rake users:process_scheduled_membership_changes"
cd $2 && bundle exec rake users:process_scheduled_membership_changes >> $LOGFILE 2>&1
echo "`date` rake users:cancel"
cd $2 && bundle exec rake users:cancel >> $LOGFILE 2>&1
echo "`date` rake users:process_sync"
cd $2 && bundle exec rake users:process_sync >> $LOGFILE 2>&1
if [ "$1" == "production" ]; then
echo "`date` rake payeezy:chargeback_report"
cd $2 && bundle exec rake payeezy:chargeback_report >> $LOGFILE 2>&1
# echo "`date` rake payeezy:account_updater_send_file_to_process"
# cd $2 && bundle exec rake payeezy:account_updater_send_file_to_process >> $LOGFILE 2>&1
# echo "`date` rake payeezy:account_updater_process_response"
# cd $2 && bundle exec rake payeezy:account_updater_process_response >> $LOGFILE 2>&1
fi
# nowadys we will run billing once per day
echo "`date` rake billing:for_today"
cd $2 && bundle exec rake billing:for_today >> $LOGFILE 2>&1
echo "`date` rake users:process_fulfillments"
cd $2 && bundle exec rake users:process_fulfillments >> $LOGFILE 2>&1 &
echo "`date` rake fulfillments:process_shipping_cost_reports"
cd $2 && bundle exec rake fulfillments:process_shipping_cost_reports >> $LOGFILE 2>&1 &
echo "`date` rake users:process_email_sync_error"
cd $2 && bundle exec rake users:process_email_sync_error >> $LOGFILE 2>&1 &
WAIT_PIDS=`jobs -l | awk '{print $2}'`
wait $WAIT_PIDS
echo "`date` rake products:send_product_list_email"
cd $2 && bundle exec rake products:send_product_list_email >> $LOGFILE 2>&1 &
echo "`date` rake mkt_tools:sync_members_to_mailchimp"
cd $2 && bundle exec rake mkt_tools:sync_members_to_mailchimp >> $LOGFILE 2>&1 &
WAIT_PIDS=`jobs -l | awk '{print $2}'`
wait $WAIT_PIDS
echo "`date` rake billing:send_prebill"
cd $2 && bundle exec rake billing:send_prebill >> $LOGFILE 2>&1 &
echo "`date` rake users:send_happy_birthday"
cd $2 && bundle exec rake users:send_happy_birthday >> $LOGFILE 2>&1 &
echo "`date` rake users:send_pillar_emails "
cd $2 && bundle exec rake users:send_pillar_emails >> $LOGFILE 2>&1 &
echo "`date` rake users:process_club_cash"
# club cash should be processed before billing. Because if we reset club cash and then we bill, new CC should not be resetted
cd $2 && bundle exec rake users:process_club_cash >> $LOGFILE 2>&1 &
# after this script we should do the BK and reports
WAIT_PIDS=`jobs -l | awk '{print $2}'`
wait $WAIT_PIDS
# fetch data from store
echo "`date` rake products:import_products_data_from_store"
cd $2 && bundle exec rake products:import_products_data_from_store >> $LOGFILE 2>&1
# fetch data from campaigns
echo "`date` rake campaigns:fetch_data"
cd $2 && bundle exec rake campaigns:fetch_data >> $LOGFILE 2>&1
# count members for each club
echo "`date` rake clubs:count_members_in_clubs"
cd $2 && bundle exec rake clubs:count_members_in_clubs >> $LOGFILE 2>&1
if [ `date +"%d"` == "01" ]; then
echo "`date` rake users:delete_testing_accounts"
cd $2 && bundle exec rake users:delete_testing_accounts >> $LOGFILE 2>&1 &
fi
# echo "`date` rake mkt_tools:sync_prospects_to_exact_target"
# cd $2 && bundle exec rake mkt_tools:sync_prospects_to_exact_target >> $LOGFILE 2>&1 &
echo "`date` rake mkt_tools:sync_prospects_to_mailchimp"
cd $2 && bundle exec rake mkt_tools:sync_prospects_to_mailchimp >> $LOGFILE 2>&1 &
# blacklist temporary unblacklisted users
echo "`date` rake users:blacklist_users_unblacklisted_temporary"
cd $2 && bundle exec rake users:blacklist_users_unblacklisted_temporary >> $LOGFILE 2>&1
if [ "$1" == "production" ]; then
echo "`date` Starting mysql dump generation and upload to S3."
cd $2 && /bin/bash script/custom/upload-master-dump.sh
fi
WAIT_PIDS=`jobs -l | awk '{print $2}'`
wait $WAIT_PIDS