overflowers,
I've been struggling for hours on end trying to publish a Go application to AWS Elastic Beanstalk.
Have followed helpful tutorials online for what I first thought was dead simple.
One of the tutorials i followed
Another one of the tutorials i followed
An examples which actually compiles on AWS for me
My project structure is now:
The following files are all in my root folder:
application.go
build.sh
Buildfile
Procfile
application.go
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.GET("/user/:name", func(c *gin.Context) {
name := c.Param("name")
c.String(http.StatusOK, "Hello %s", name)
})
router.Run(":5000")
}
build.sh
go get "github.com/gin-gonic/gin" //Have tried without quotation marks
go build application.go
Buildfile
make: ./build.sh
Procfile
web: bin/application
I have also read the documentation on AWS website. And from what I can tell- my code, and the code in the demos referred to above, is correct.
I compress the enire contents of my root folder to a .zip file and upload to AWS through the web portal.
It fails...and in the error logs i can read:
2020/08/28 23:17:38.902079 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/28 23:17:38.902095 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2020/08/28 23:17:38.902100 [INFO] Executing instruction: Golang Specific Build Application
2020/08/28 23:17:38.902104 [INFO] checking Buildfile...
2020/08/28 23:17:38.902110 [INFO] building Golang application with Buildfile
2020/08/28 23:17:38.902148 [INFO] Running command /bin/sh -c systemctl show -p PartOf make.service
2020/08/28 23:17:38.908345 [WARN] Warning: process make is already registered...
Deregistering the process ...
2020/08/28 23:17:38.908368 [INFO] Running command /bin/sh -c systemctl show -p PartOf make.service
2020/08/28 23:17:38.913626 [INFO] Running command /bin/sh -c systemctl is-active make.service
2020/08/28 23:17:38.916919 [INFO] Running command /bin/sh -c systemctl disable make.service
2020/08/28 23:17:39.002192 [INFO] Running command /bin/sh -c systemctl daemon-reload
2020/08/28 23:17:39.086778 [INFO] Running command /bin/sh -c systemctl reset-failed
2020/08/28 23:17:39.092606 [INFO] Running command /bin/sh -c systemctl daemon-reload
2020/08/28 23:17:39.166648 [INFO] Running command /bin/sh -c systemctl reset-failed
2020/08/28 23:17:39.170861 [INFO] Running command /bin/sh -c systemctl is-enabled eb-app.target
2020/08/28 23:17:39.174735 [INFO] Running command /bin/sh -c systemctl enable eb-app.target
2020/08/28 23:17:39.251327 [INFO] Running command /bin/sh -c systemctl start eb-app.target
2020/08/28 23:17:39.256334 [INFO] Running command /bin/sh -c systemctl enable make.service
2020/08/28 23:17:39.338502 [INFO] Running command /bin/sh -c systemctl show -p PartOf make.service
2020/08/28 23:17:39.344691 [INFO] Running command /bin/sh -c systemctl is-active make.service
2020/08/28 23:17:39.348280 [INFO] Running command /bin/sh -c systemctl start make.service
2020/08/28 23:17:39.358198 [ERROR] startProcess Failure: starting process "make" failed: Command /bin/sh -c systemctl start make.service failed with error exit status 1. Stderr:Job for make.service failed because the control process exited with error code. See "systemctl status make.service" and "journalctl -xe" for details.
2020/08/28 23:17:39.358222 [ERROR] An error occurred during execution of command [app-deploy] - [Golang Specific Build Application]. Stop running the command. Error: build application failed on command ./build.sh with error: startProcess Failure: starting process "make" failed: Command /bin/sh -c systemctl start make.service failed with error exit status 1. Stderr:Job for make.service failed because the control process exited with error code. See "systemctl status make.service" and "journalctl -xe" for details.
Unfortunately I don't have much experience of this kind of server configuration or any other deployment operations. So I do not understand "process make is already registered..."
...Perhaps someone more experienced in these areas might know what to make of this?
Cheers!
NOTE: The project has been able to compile and run on my computer all the time. It just fails when i try deploying it on the Elastic Beanstalk.
EDIT: Have now also tried deploying with the AWS Command Line Interface. In this case the logfile eb-activity tells me:
Executing: HOME=/tmp /opt/elasticbeanstalk/lib/ruby/bin/ruby /opt/elasticbeanstalk/lib/ruby/bin/foreman start --procfile /tmp/d20200829-3130-13cz1sh/eb-buildtask-0 --root /var/app/staging --env /var/elasticbeanstalk/staging/elasticbeanstalk.env
/opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.2.0/gems/foreman-0.78.0/lib/foreman/process.rb:54:in `spawn': Permission denied - ./build.sh (Errno::EACCES)
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.2.0/gems/foreman-0.78.0/lib/foreman/process.rb:54:in `block in run'
This may occur when the build.sh script lacks executable permissions. When that's the case "make.service" on beanstalk can't execute the script and an error is generated.
If you are developing on a unix machine try to chmod +x build.sh before deployment.
If you are developing on a windows machine you can't set the unix file attribute. But you can use this trick with Buildfile and deploy this way.
Buildfile
make: chmod +x build.sh; ./build.sh
This will make build.sh executable when the make service runs.
I also encountered this issue when migrating the deployment of my Golang application to the Amazon Linux 2 platform from Amazon Linux 1 platform. I was experiencing a similar error in the build process:
2021/07/10 16:33:21.411538 [ERROR] An error occurred during execution of command [app-deploy] - [Golang Specific Build Application]. Stop running the command. Error: build application failed on command ./build.sh with error: startProcess Failure: starting process "make" failed: Command /bin/sh -c systemctl start make.service failed with error exit status 1. Stderr:Job for make.service failed because the control process exited with error code. See "systemctl status make.service" and "journalctl -xe" for details.
After looking in to the systemctl status, as suggested in the error, I figured out the linux user "webapp" did not seem to have the correct permissions.
I added "webapp" to the sudoers file and now that build process finishes, and the deploy is able to succeed.
# User rules for webapp user
webapp ALL=(ALL) NOPASSWD:ALL
Related
I am deploying the web app in aws elastic bean .The code run fine in localhost but fail with error 502.
Here are my log in eb with warn:
2022/11/12 18:05:10.175659 [INFO] Cleaned ebextensions subdirectories from app staging directory.
2022/11/12 18:05:10.175664 [INFO] Executing instruction: RunAppDeployPreDeployHooks
2022/11/12 18:05:10.175694 [INFO] Running command /bin/sh -c uname -m
2022/11/12 18:05:10.177374 [INFO] x86_64
2022/11/12 18:05:10.177397 [INFO] Executing platform hooks in .platform/hooks/predeploy/
2022/11/12 18:05:10.177417 [INFO] The dir .platform/hooks/predeploy/ does not exist
2022/11/12 18:05:10.177421 [INFO] Finished running scripts in /var/app/staging/.platform/hooks/predeploy
2022/11/12 18:05:10.177428 [INFO] Executing instruction: stop X-Ray
2022/11/12 18:05:10.177433 [INFO] stop X-Ray ...
2022/11/12 18:05:10.177442 [INFO] Running command /bin/sh -c systemctl show -p PartOf xray.service
2022/11/12 18:05:10.315088 [WARN] stopProcess Warning: process xray is not registered
2022/11/12 18:05:10.315115 [INFO] Running command /bin/sh -c systemctl stop xray.service
2022/11/12 18:05:10.323680 [INFO] Executing instruction: stop proxy
2022/11/12 18:05:10.323699 [INFO] Running command /bin/sh -c systemctl show -p PartOf httpd.service
2022/11/12 18:05:10.327933 [WARN] deregisterProcess Warning: process httpd is not registered, skipping...
2022/11/12 18:05:10.327948 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2022/11/12 18:05:10.334136 [WARN] deregisterProcess Warning: process nginx is not registered, skipping...
2022/11/12 18:05:10.334149 [INFO] Executing instruction: FlipApplication
2022/11/12 18:05:10.334154 [INFO] Fetching environment variables...
2022/11/12 18:05:10.334172 [INFO] Running command /bin/sh -c uname -m
2022/11/12 18:05:10.335672 [INFO] x86_64
2022/11/12 18:05:10.335768 [INFO] Purge old process...
2022/11/12 18:05:10.335786 [INFO] Removing /var/app/current/ if it exists
2022/11/12 18:05:10.335796 [INFO] Renaming /var/app/staging/ to /var/app/current/
2022/11/12 18:05:10.335811 [INFO] Register application processes...
2022/11/12 18:05:10.335818 [INFO] Registering the proc: web
Here are the log with error:
2022/11/12 18:18:19 [error] 3971#3971: *1 connect() failed (111: Connection refused) while connecting to upstream,
I have a Docker-backed AWS Elastic Beanstalk application. I pull the image from a private AWS ECR.
However, I get the "Instance deployment failed..." error. In the logs, I see
2021/12/08 21:57:49.261047 [INFO] Executing instruction: RestartAppServer
2021/12/08 21:57:49.261050 [INFO] Restarting customer application...
2021/12/08 21:57:49.261065 [INFO] detected current app is not docker compose app
2021/12/08 21:57:49.261073 [INFO] Running command /bin/sh -c systemctl show -p PartOf eb-docker.service
2021/12/08 21:57:49.265842 [WARN] stopProcess Warning: process eb-docker is not registered > 2021/12/08 21:57:49.265859 [INFO] Running command /bin/sh -c systemctl stop eb-docker.service
2021/12/08 21:57:49.270477 [INFO] Running command /bin/sh -c systemctl show -p PartOf eb-docker.service
2021/12/08 21:57:49.275369 [ERROR] An error occurred during execution of command [restart-app-server] - [RestartAppServer]. Stop running the command. Error: startProcess Failure: process "eb-docker" is not registered
What do I do about this? How to register "eb-docker"?
My Dockerrun.aws.json is quite simple
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "**.dkr.ecr.eu-central-1.amazonaws.com/*:*",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "80"
}
]
}
I have build a cicd pipeline using AWS codepipeline.
Source is coming from Github which successed. Build is also successed.
I am using Corretto 11 running on 64bit Amazon Linux 2 as a platform in Elastic Beanstalk as Java 8 running on 64bit Amazon Linux shows as it's being deprecated.
I'm getting error during deployment to AWS Elastic Beanstalk.
Action execution failed
Deployment completed, but with errors: Failed to deploy application. Unsuccessful command execution on instance id(s) 'i-03b7a9c8a86ffde8e'. Aborting the operation. [Instance: i-03b7a9c8a86ffde8e] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. Instance deployment failed. For details, see 'eb-engine.log'.
I checked eb-engine.log file and see below error message.
...
...
2021/11/07 05:01:18.765214 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /tmp/extracted_app_source_bundle
2021/11/07 05:01:18.765227 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /tmp/extracted_app_source_bundle
2021/11/07 05:01:19.122461 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /tmp/extracted_app_source_bundle successfully
2021/11/07 05:01:19.122560 [INFO] app source bundle is zip file ...
2021/11/07 05:01:19.122566 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2021/11/07 05:01:19.122578 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2021/11/07 05:01:19.498171 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2021/11/07 05:01:19.498694 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2021/11/07 05:01:19.498712 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2021/11/07 05:01:19.498717 [INFO] Executing instruction: Java Specific Build Application
2021/11/07 05:01:19.498724 [INFO] no buildfile found, skip building java application
2021/11/07 05:01:19.498731 [INFO] old env file for build tasks does not exist
2021/11/07 05:01:19.498742 [INFO] Executing instruction: CheckProcfileForJavaApplication
2021/11/07 05:01:19.498776 [ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForJavaApplication]. Stop running the command. Error: there is no Procfile and no .jar file at root level of your source bundle
2021/11/07 05:01:19.498786 [INFO] Executing cleanup logic
2021/11/07 05:01:19.498869 [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":1636261279,"severity":"ERROR"}]}]}
...
...
Below is my buildspec.yml file.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
commands:
- echo install
pre_build:
commands:
- echo pre_build
build:
commands:
- mvn package
- echo build
post_build:
commands:
- echo post_build
artifacts:
files:
- target/course_reviews_backend-0.0.1-SNAPSHOT.jar
PLEASE HELP!!
Any help would be appericated. Thanks in advance.
I'm trying to deploy a flask app that predicts whether a lung x-ray picture is COVID-19 positive using a Tensorflow CNN. It is running on python 3.7
This is my requirements.txt
tensorflow==2.4.0
Flask==1.1.2
Keras==2.4.3
numpy==1.19.5
Pillow==8.3.1
After deployment it, the environment's health status is labelled severe with a '502 Bad gateway' error.
These are the errors in the eb-engine.log
2021/08/23 10:47:40.676374 [INFO] Installing dependencies with requirements.txt by using Pip
2021/08/23 10:47:40.676387 [INFO] Running command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt
2021/08/23 10:47:48.296114 [INFO] Collecting tensorflow==2.4.0
Downloading tensorflow-2.4.0-cp38-cp38-manylinux2010_x86_64.whl (394.8 MB)
2021/08/23 10:47:48.300932 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with requirements.txt file with error Command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt failed with error exit status 2. Stderr:ERROR: Exception:
Traceback (most recent call last):
File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
status = self.run(options, args)
File "... repeats itself until here:
File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/pip/_vendor/msgpack/fallback.py", line 896, in _pack
return self._buffer.write(obj)
MemoryError
2021/08/23 10:47:48.300957 [INFO] Executing cleanup logic
2021/08/23 10:47:48.309000 [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 to install application dependencies. The deployment failed.","timestamp":1629715668,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1629715668,"severity":"ERROR"}]}]}
2021/08/23 10:47:48.312983 [INFO] Platform Engine finished execution on command: app-deploy
2021/08/23 12:34:34.689865 [INFO] Starting...
2021/08/23 12:34:34.689926 [INFO] Starting EBPlatform-PlatformEngine
2021/08/23 12:34:34.689965 [INFO] reading event message file
2021/08/23 12:34:34.690627 [INFO] no eb envtier info file found, skip loading env tier info.
2021/08/23 12:34:34.690716 [INFO] Engine received EB command cfn-hup-exec
why is AWS-Beanstalk failing to install Tensorflow?
I changed the environment EC2 capacity from t2.small to c5.xlarge and the problem was solved.
Your application needs more memory space.
i am new to aws and django. I was tryinh to upload my code to aws elastic beanstalk using code commit while i am getting the following error
2020/03/12 13:42:30.200017 [ERROR] Command timed out after 300 seconds
2020/03/12 13:42:30.202535 [ERROR] Command /bin/sh [-c python3 -m pipenv install -r requirements.txt --skip-lock] failed with error signal: killed
2020/03/12 13:42:30.204812 [ERROR] An error occurred during execution of command [app-deploy] - [SetUpPythonEnvironment]. Stop running the command.
Error: fail to install dependencies with requirements.txt file with error Command /bin/sh [-c python3 -m pipenv install -r requirements.txt --skip-lock] failed with error signal: killed
2020/03/12 13:42:30.204825 [INFO] Executing cleanup logic
2020/03/12 13:42:30.210383 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[]}]}
2020/03/12 13:42:30.211588 [INFO] Platform Engine finished execution on command: app-deploy