mercredi 13 août 2014

Django: "GeoIP chemin doit être un fichier valide ou un répertoire" sur Amazon Elastic Beanstalk - Stack Overflow


I created a custom AMI containing all the libraries that I need for my project, among these I installed the C libraries for MaxMind GeoIP, then I downloaded the GeoCityLite.dat to /home/ec2-user/geoip/. I exported the environment variable CG_GEOIP (as /home/ec2-user/geoip/) and even GEOIP_LIBRARY_PATH (pointing it to the location of my installation that is: /usr/lib64/libGeoIP.so). But Django does not find it, and I get "GeoIP path must be a valid file or directory". (I'm sure the file is there, by connecting via SSH to my instance I can see it). How can I solve my issue?


ps: by using printenv while connected to my instance no one of the environment variables that I defined in Beanstalk environment settings is displayed... why? (anyway this is not the problem, since variables that I defined are somehow resolved by my app... in fact, the configuration for the database connection is in an environment variable and I know that is resolved since synchdb command works, and I can see the generated tables on my RDS instance)




If you are trying to get environment variables by connecting to EC2 instance, there are couple of issues.



  • Elastic Beanstalk container runs as virtualenv. So $ python in command line is not exactly the same interpreter as the one executing your container code.

  • Elastic Beanstalk environment executes initialization scripts, which populate environment variables for the container. Environment variables are not system environment variables, they are available to the code running in the container, and to container commands only.


As for the first part of your question, I would check what values do you get in the container and take it from there.


import os

cg_geoip = os.environ['CG_GEOIP']
geoip_library_path = os.environ['GEOIP_LIBRARY_PATH']


I created a custom AMI containing all the libraries that I need for my project, among these I installed the C libraries for MaxMind GeoIP, then I downloaded the GeoCityLite.dat to /home/ec2-user/geoip/. I exported the environment variable CG_GEOIP (as /home/ec2-user/geoip/) and even GEOIP_LIBRARY_PATH (pointing it to the location of my installation that is: /usr/lib64/libGeoIP.so). But Django does not find it, and I get "GeoIP path must be a valid file or directory". (I'm sure the file is there, by connecting via SSH to my instance I can see it). How can I solve my issue?


ps: by using printenv while connected to my instance no one of the environment variables that I defined in Beanstalk environment settings is displayed... why? (anyway this is not the problem, since variables that I defined are somehow resolved by my app... in fact, the configuration for the database connection is in an environment variable and I know that is resolved since synchdb command works, and I can see the generated tables on my RDS instance)



If you are trying to get environment variables by connecting to EC2 instance, there are couple of issues.



  • Elastic Beanstalk container runs as virtualenv. So $ python in command line is not exactly the same interpreter as the one executing your container code.

  • Elastic Beanstalk environment executes initialization scripts, which populate environment variables for the container. Environment variables are not system environment variables, they are available to the code running in the container, and to container commands only.


As for the first part of your question, I would check what values do you get in the container and take it from there.


import os

cg_geoip = os.environ['CG_GEOIP']
geoip_library_path = os.environ['GEOIP_LIBRARY_PATH']

0 commentaires:

Enregistrer un commentaire