I updated AWS platform from "Python 3.6 running on 64bit Amazon Linux" to "Python 3.7 running on 64bit Amazon Linux 2" and I'm not able to execute crons because I don't know how to add reference for Django environment settings (stored to EB Environment properties) there. Could you help me?
On the old platform everything works fine with this ".ebextensions/cron.config" setup:
files:
"/etc/cron.d/mycron":
mode: "000644"
owner: root
group: root
content: |
3 ** ** ** ** root /usr/local/bin/script.sh > /home/ec2-user/script.log 2>&1
"/usr/local/bin/script.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
date > /tmp/date
# actual script content
source /opt/python/run/venv/bin/activate
source /opt/python/current/env
cd /opt/python/current/app/
python manage.py send_notification
exit 0
I know that I have to make changes on Linux 2 platform and I have to run activate -script from different location and this is what I have now:
files:
"/etc/cron.d/mycron":
mode: "000644"
owner: root
group: root
content: |
3 ** ** ** ** root /usr/local/bin/script.sh > /home/ec2-user/script.log 2>&1
"/usr/local/bin/script.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
date > /tmp/date
# actual script content
source /var/app/venv/*/bin/activate
cd /var/app/current/
python manage.py send_notification
exit 0
I have also noticed that everything works fine when I try to do the same from .platform/hooks/predeploy and executing python from /var/app/staging, but that path is not available later on. The problem is that os.Environment - variables were not loaded from the EB configuration and I got KeyError from os.Environment key - reference.
Edited by: NanNull on Nov 10, 2020 9:36 PM
Edited by: NanNull on Nov 10, 2020 9:37 PM
Edited by: NanNull on Nov 10, 2020 9:45 PM
Edited by: NanNull on Nov 10, 2020 9:47 PM
Edited by: NanNull on Nov 10, 2020 9:54 PM