1

I have a Django application and I'm trying to deploy to my AWS EB Environment. It's a project that my friend and I are working on. I an trying to run the command eb deploy however though I get this:

Alert: The platform version that your environment is using isn't recommended. There's a recommended version in the same platform branch.

Creating application version archive "app-3d19-210731_133226".
Uploading Prod Rest API/app-3d19-210731_133226.zip to S3. This may take a while.
Upload Complete.
2021-07-31 17:32:29    INFO    Environment update is starting.
2021-07-31 17:32:33    INFO    Deploying new version to instance(s).
2021-07-31 17:32:36    ERROR   Instance deployment failed. For details, see 'eb-engine.log'.
2021-07-31 17:32:39    ERROR   [Instance: i-05761282d68083a51] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error..
2021-07-31 17:32:39    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2021-07-31 17:32:39    ERROR   Unsuccessful command execution on instance id(s) 'i-05761282d68083a51'. Aborting the operation.
2021-07-31 17:32:39    ERROR   Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.

I checked the eb-engine.og and this is what I get:

2021/07/31 17:19:47.104584 [INFO] Executing instruction: StageApplication
2021/07/31 17:19:47.111204 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2021/07/31 17:19:47.111230 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2021/07/31 17:19:47.154001 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2021/07/31 17:19:47.156956 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2021/07/31 17:19:47.156982 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2021/07/31 17:19:47.157046 [INFO] Following platform hooks will be executed in order: [install_supervisor.sh]
2021/07/31 17:19:47.157060 [INFO] Running platform hook: .platform/hooks/prebuild/install_supervisor.sh
2021/07/31 17:19:47.157342 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/install_supervisor.sh failed with error fork/exec .platform/hooks/prebuild/install_supervisor.sh: no such file or directory 

2021/07/31 17:19:47.157349 [INFO] Executing cleanup logic
2021/07/31 17:19:47.157565 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1627751987,"severity":"ERROR"}]}]}

2021/07/31 17:19:47.159200 [INFO] Platform Engine finished execution on command: app-deploy

I'm really confused on why this is occuring because for my friend who has the same repo, he is able to eb deploy fine but I can't for some reason.

This is my file structure:

my-app/
├─ .ebextensions/
│  ├─ 01_django.config
├─ .elasticbeanstalk/
│  ├─ config.yml
├─ .platform/
│  ├─ files/
│  │  ├─ supervisor.ini
│  ├─ hooks/
│  │  ├─ prebuild/
│  │  │  ├─ install_supervisor.sh
├─ other files/

where my other files are my actual Django code itself.

01_django.config

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: RestAPI.wsgi:application
  aws:elasticbeanstalk:environment:proxy:staticfiles:
    /static: static

config.yml

branch-defaults:
  main:
    environment: Prodrestapi-env
environment-defaults:
  Prodrestapi-env:
    branch: null
    repository: null
global:
  application_name: Prod Rest API
  default_ec2_keyname: aws-eb
  default_platform: Python 3.8 running on 64bit Amazon Linux 2
  default_region: us-east-2
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: eb-cli
  sc: git
  workspace_type: Application

supervisor.ini

# Create celery configuraiton script
[program:celeryd-worker]
; Set full path to celery program if using virtualenv
command=sh /var/app/current/scripts/worker.sh

directory=/var/app/current
; user=nobody
numprocs=1
stdout_logfile=/var/log/celery-worker.log
stderr_logfile=/var/log/celery-worker.log
autostart=true
autorestart=true
startsecs=60

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 60

; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true

; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998

install_supervisor.sh

#!/bin/sh
sudo amazon-linux-extras enable epel

sudo yum install -y epel-release

sudo yum -y update

sudo yum -y install supervisor

sudo systemctl start supervisord

sudo systemctl enable supervisord

sudo cp .platform/files/supervisor.ini /etc/supervisord.d/celery.ini

sudo supervisorctl reread

sudo supervisorctl update

I"m just really confused on why it's not deploying properly because the install_supervisor.sh file is clearly in the folder.

Any and all help will be really appreciate. Thank you so much!

Tony Hoan Trinh
  • 455
  • 4
  • 13
  • 2
    I fixed the problem following Ravi's solution in this thread (https://stackoverflow.com/questions/63924466/platform-hooks-no-such-file-or-directory-when-deploying-django-app-to-aws-e) – Tony Hoan Trinh Aug 01 '21 at 00:48

0 Answers0