Skip to content

Commit 803be79

Browse files
authored
Merge pull request #1901 from pburkholder/pb/clean-up-cron
Some fixes to Cron
2 parents d5d50c6 + 84f1a88 commit 803be79

File tree

1 file changed

+75
-67
lines changed

1 file changed

+75
-67
lines changed

.circleci/cron.sh

Lines changed: 75 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,75 +4,83 @@
44
# a non-zero exit code
55
set -e
66

7-
echo "Logging into cloud.gov"
7+
# Set # of failures to 0
8+
F=0
9+
10+
function run_production_tasks() {
11+
# === PRODUCTION environment ===================================================
12+
echo "Running tasks in Production..."
13+
14+
PROD_TASK="cf run-task touchpoints-production-sidekiq-worker --wait -c"
15+
# Users
16+
$PROD_TASK "rake scheduled_jobs:send_one_week_until_inactivation_warning" || F=$((F+=1))
17+
$PROD_TASK "rake scheduled_jobs:send_two_weeks_until_inactivation_warning" || F=$((F+=1))
18+
$PROD_TASK "rake scheduled_jobs:deactivate_inactive_users" || F=$((F+=1))
19+
20+
# Forms
21+
# $PROD_TASK "rake scheduled_jobs:send_daily_notifications" || F=$((F+=1))
22+
# $PROD_TASK "rake scheduled_jobs:send_weekly_notifications" || F=$((F+=1))
23+
# $PROD_TASK "rake scheduled_jobs:check_expiring_forms" || F=$((F+=1))
24+
# $PROD_TASK "rake scheduled_jobs:archive_forms" || F=$((F+=1))
25+
$PROD_TASK "rake scheduled_jobs:notify_form_managers_of_inactive_forms" || F=$((F+=1))
26+
# $PROD_TASK "rake scheduled_jobs:delete_submissions_trash" || F=$((F+=1))
27+
echo "Production tasks have completed."
28+
}
29+
30+
31+
function run_staging_tasks() {
32+
# === STAGING environment ======================================================
33+
echo "Running tasks in Staging..."
34+
35+
STAGING_TASK="cf run-task touchpoints-staging-sidekiq-worker --wait -c"
36+
37+
# Users
38+
$STAGING_TASK "rake scheduled_jobs:send_one_week_until_inactivation_warning" || F=$((F+=1))
39+
$STAGING_TASK "rake scheduled_jobs:send_two_weeks_until_inactivation_warning" || F=$((F+=1))
40+
$STAGING_TASK "rake scheduled_jobs:deactivate_inactive_users" || F=$((F+=1))
41+
42+
# Forms
43+
$STAGING_TASK "rake scheduled_jobs:send_daily_notifications" || F=$((F+=1))
44+
$STAGING_TASK "rake scheduled_jobs:send_weekly_notifications" || F=$((F+=1))
45+
$STAGING_TASK "rake scheduled_jobs:check_expiring_forms" || F=$((F+=1))
46+
$STAGING_TASK "rake scheduled_jobs:archive_forms" || F=$((F+=1))
47+
$STAGING_TASK "rake scheduled_jobs:notify_form_managers_of_inactive_forms" || F=$((F+=1))
48+
# $STAGING_TASK "rake scheduled_jobs:delete_submissions_trash" || F=$((F+=1))
49+
50+
echo "Staging tasks have completed."
51+
}
52+
53+
function run_demo_tasks() {
54+
# === DEMO environment =========================================================
55+
echo "Running tasks in Demo..."
56+
DEMO_TASK="cf run-task touchpoints-demo-sidekiq-worker --wait -c"
57+
58+
# Users
59+
$DEMO_TASK "rake scheduled_jobs:send_one_week_until_inactivation_warning" || F=$((F+=1))
60+
$DEMO_TASK "rake scheduled_jobs:send_two_weeks_until_inactivation_warning" || F=$((F+=1))
61+
$DEMO_TASK "rake scheduled_jobs:deactivate_inactive_users" || F=$((F+=1))
62+
63+
# Forms
64+
$DEMO_TASK "rake scheduled_jobs:send_daily_notifications" || F=$((F+=1))
65+
$DEMO_TASK "rake scheduled_jobs:send_weekly_notifications" || F=$((F+=1))
66+
$DEMO_TASK "rake scheduled_jobs:check_expiring_forms" || F=$((F+=1))
67+
$DEMO_TASK "rake scheduled_jobs:archive_forms" || F=$((F+=1))
68+
$DEMO_TASK "rake scheduled_jobs:notify_form_managers_of_inactive_forms" || F=$((F+=1))
69+
# $DEMO_TASK "rake scheduled_jobs:delete_submissions_trash" || F=$((F+=1))
70+
71+
echo "Demo tasks have completed."
72+
}
73+
74+
echo "Logging into cloud.gov non-prod"
875
cf login -a $CF_API_ENDPOINT -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORG -s $CF_SPACE
9-
10-
#
11-
# === STAGING environment ======================================================
12-
#
13-
14-
echo "Running tasks in Staging..."
15-
16-
# Users
17-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:send_one_week_until_inactivation_warning"
18-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:send_two_weeks_until_inactivation_warning"
19-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:deactivate_inactive_users"
20-
21-
# Forms
22-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:send_daily_notifications"
23-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:send_weekly_notifications"
24-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:check_expiring_forms"
25-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:archive_forms"
26-
cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:notify_form_managers_of_inactive_forms"
27-
# cf run-task touchpoints-staging-sidekiq-worker -c "rake scheduled_jobs:delete_submissions_trash"
28-
29-
echo "Staging tasks have completed."
30-
31-
#
32-
# === DEMO environment =========================================================
33-
#
34-
35-
echo "Running tasks in Demo..."
36-
37-
# Users
38-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:send_one_week_until_inactivation_warning"
39-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:send_two_weeks_until_inactivation_warning"
40-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:deactivate_inactive_users"
41-
42-
# Forms
43-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:send_daily_notifications"
44-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:send_weekly_notifications"
45-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:check_expiring_forms"
46-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:archive_forms"
47-
cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:notify_form_managers_of_inactive_forms"
48-
# cf run-task touchpoints-demo-sidekiq-worker -c "rake scheduled_jobs:delete_submissions_trash"
49-
50-
echo "Demo tasks have completed."
51-
76+
run_staging_tasks
77+
run_demo_tasks
5278
cf logout
5379

54-
#
55-
# === PRODUCTION environment ===================================================
56-
#
57-
58-
echo "Logging into cloud.gov"
80+
echo "Logging into cloud.gov production environment"
5981
cf login -a $CF_API_ENDPOINT -u $CF_PRODUCTION_SPACE_DEPLOYER_USERNAME -p $CF_PRODUCTION_SPACE_DEPLOYER_PASSWORD -o $CF_ORG -s prod
60-
61-
echo "Running tasks in Production..."
62-
63-
# Users
64-
cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:send_one_week_until_inactivation_warning"
65-
cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:send_two_weeks_until_inactivation_warning"
66-
cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:deactivate_inactive_users"
67-
68-
# Forms
69-
# cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:send_daily_notifications"
70-
# cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:send_weekly_notifications"
71-
# cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:check_expiring_forms"
72-
# cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:archive_forms"
73-
cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:notify_form_managers_of_inactive_forms"
74-
# cf run-task touchpoints-production-sidekiq-worker -c "rake scheduled_jobs:delete_submissions_trash"
75-
76-
echo "Production tasks have completed."
77-
82+
run_production_tasks
7883
cf logout
84+
85+
echo "$0 exiting with failure count: $F"
86+
exit $F

0 commit comments

Comments
 (0)