Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Cronjob #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .ebextensions/cron-linux.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
###################################################################################################
#### Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
####
#### Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
#### except in compliance with the License. A copy of the License is located at
####
#### http://aws.amazon.com/apache2.0/
####
#### or in the "license" file accompanying this file. This file is distributed on an "AS IS"
#### BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#### License for the specific language governing permissions and limitations under the License.
###################################################################################################

files:
"/etc/cron.d/drupalcron":
mode: "000644"
owner: root
group: root
content: |
0,10,20,30,40,50 * * * * root /var/www/html/.platform/cron/drupal.sh
commands:
remove_old_cron:
command: "rm -f /etc/cron.d/drupalcron.bak"

23 changes: 23 additions & 0 deletions .platform/cron/drupal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e


# The Apache webserver runs as webapp, so we need to execute
# the deploy procedure with that user, otherwise we might create
# inacessible files under sites/default/files .
# By default, we login using `ec2-user`.
if [ "$(whoami)" != "webapp" ]; then

# As root, we make sure we have access to the environment variables.
chmod 644 /opt/elasticbeanstalk/deployment/env

SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
sudo -uwebapp "$SCRIPTPATH/drupal.sh"
exit 0
fi

export $(cat /opt/elasticbeanstalk/deployment/env | xargs)

cd /var/www/html || exit 1
DRUSH="./vendor/bin/drush"
$DRUSH core-cron