Deployment of Go App on AWS EC2

Hello Guys , Good Evening . Recently I come across one issue while deploying my Go app onto Amazon Web Services EC2. Actually in my demo project, I have used for reading the values from properties file.
Kindly take a note

     |------------> resources
                           |----------> ResourceManager.go
                          |------------> DemoConstant.go
     |------------------------------> main.go

   ( Here I've not given the complete structure )
               exception.message.could.not.login=Could not log you in.
      id not registered.    

               package constants
               var COULD_NOT_LOGIN        = "exception.message.could.not.login"
               var EMAIL_NOT_REGISTERED   = "" 

               package utils
               import (

                var PropertyFile = []string{"${HOME}/GoProject/src/MindBowser/MBIS/resources/"}

                var Props, _ = properties.LoadFiles(PropertyFile, properties.UTF8, true)

                 type ResourceManager struct {

                 func (res ResourceManager) GetProperty(strs string) string {

                 message := ""
                 var ok bool
                  message, ok = Props.Get(strs)
                  if !ok {
	                 return Props.MustGet("not.found")
                   } else {
	               return message

                 package main
                  import  (
                   var resourceManager *utils.ResourceManager = &utils.ResourceManager{}
                   func main(){

                   /* In above lines I'm just printing the exception messages */

So its working is simple and this one is the RESTful Web App and I haven’t included WebService and other layers.

So this demo project is working locally on Ubuntu OS. But after deploying it to AWS EC2, I’m getting the Error

The above code is completely fine and its working locally.

MB@MB-VirtualBox:~/GoProject/src/MindBowser/MBIS/main <-----Here I’m creating binary file which I’m trying to deploy. while executing this errors are coming.

Kindly try to suggest the solution on top priority basis.

Hello guys , does anybody knows why this error is coming ? If needed anything, let me know .

Just a gues, but the error is there because the file is not.

Make sure that the file /root/GoProject/src/MindBrowser/MBIS/resources/ exist and is readable for the user that runs the program.

Also given the code you’ve shown to us, it seems as if it is running as root. I’d try to avoid that unless necessary.

Hi Mr. Nobbz, Thanks for your reply. When I’m running it locally it is working fine but when trying to run on EC2 it showing that error. And when I’m making binary to deploy , it is considering the too. Did you know how to check all the files uploaded ?

Since I do not know anythiong about EC2, and nothing about your deployment process, I can’t tell you nothing reagrding this. I do assume that you simply upload your stuff using SCP or similar, and have full control over which data is transfered and to which place.

If not you have to change your mechanism of how your property file is discovered.

But another thing I just realise is, that in your first post you call the file while the code searches for, EC2 is baked by linux and therefore case sensitive, please make sure the complete path exists AND the casing is correct! You dev machine is probably Mac or Windows, those filesystems are very forgiving casing stuff…

Oh sorry to say but the file name is “” , mistakenly I’d put “”.

Then we can boil it down to the deployment/discovery of the file. You have to check your deployment process and make sure the file is at a place where your executable can find it and has set correct ownership and permissions.

Common sense is to put configuration in /etc/$APP_NAME

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.