Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make.service fails when deploying Go project file to AWS Elastic Beanstalk

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'

AWS Management Console screenshot of my failed deploy

like image 217
Gustav Lindström Avatar asked Nov 22 '25 06:11

Gustav Lindström


1 Answers

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.

like image 155
mbu Avatar answered Nov 24 '25 05:11

mbu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!