Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cern-drupal-distribution
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal
paas
cern-drupal-distribution
Commits
5c0e9e33
Commit
5c0e9e33
authored
4 years ago
by
Francisco Borges Aurindo Barros
Committed by
Dimitra Chatzichrysou
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Drupal cron
parent
e2f3ecf8
No related branches found
No related tags found
1 merge request
!16
Drupal cron
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
images/drupal-operations-scripts/run-cron.sh
+44
-0
44 additions, 0 deletions
images/drupal-operations-scripts/run-cron.sh
with
44 additions
and
0 deletions
images/drupal-operations-scripts/run-cron.sh
0 → 100644
+
44
−
0
View file @
5c0e9e33
#!/bin/sh
# The script triggers a CronTask inside of Drupal, following these steps:
# 1. Retrieve the cron_key of the website
# 2. Make a http request to the website using the key in order to trigger a CronTask
# Issue link: https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/437
# Note: If in the future we want to have more periodic actions made to the Drupalsites
# or want to trigger CronTasks in a different way, all we need is to edit this script.
# The DrupalSite operator is only involved to create a CronJob that executes this script.
usage
()
{
echo
"Usage:
$0
--site <site>"
1>&2
;
exit
1
;
}
# Options
ARGS
=
$(
getopt
-o
's:'
--long
'site:'
--
"
$@
"
)
||
exit
1
eval
"set --
$ARGS
"
while
true
;
do
case
"
$1
"
in
(
-s
|
--site
)
export
site
=
"
$2
"
;
shift
2
;;
(
--
)
shift
;
break
;;
(
*
)
usage
;;
esac
done
[[
-z
"
$site
"
]]
&&
usage
cron_key
=
$(
drush state-get system.cron_key
--format
=
string
)
if
echo
"
$cron_key
"
|
grep
-Eq
'^[:alnum:]_-]+$'
;
then
# key can contain alphabetic, numeric, and two special characters.
echo
"
$(
date
)
: [
${
site
}
] Error cron key not valid. Website might be broken."
continue
fi
HTTP_CODE
=
$(
curl
--location
--silent
-L
-w
"%{http_code}
\n
"
"http://
${
site
}
/cron/
${
cron_key
}
"
-o
/dev/null
)
case
$HTTP_CODE
in
204
)
echo
"
$(
date
)
: [
${
site
}
]
${
HTTP_CODE
/204/OK
}
"
# Logs not added since pod logs should suffice ? >> "$LOGFILE_MASTER" 204 No Content -> success
;;
*
)
echo
"
$(
date
)
: [
${
site
}
] Error code, expected 204, got
${
HTTP_CODE
}
"
exit
1
;;
esac
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment