Elastic Beanstalk stops at EbExtensionPostBuild - amazon-elastic-beanstalk

I am having a problem deploying an EB instance with a custom .ebextensions file. This is the relevant part in that file:
container_commands:
01_migrate:
command: 'python db_migrate.py'
02_npm_build:
command: 'npm install && npm run prod'
As you can see, these commands are for migrating my PostgreSQL database (via a Flask backend) and building my React .jsx files.
If I leave these commands out, the deployment completes perfectly well. However, once I put them in, looking at the eb-activity.log it stalls at this part forever (as far as I can tell):
[2017-04-10T02:39:24.106Z] INFO [3023] - [Application deployment app-613e-170409_223418#1/StartupStage0/EbExtensionPostBuild] : Starting activity...
I also get this message on the Health overview in the console (this is after 1 day):
Performing application deployment (running for 1 day).
I have also tried to deploy it without those container_commands, and then including it back after the successful initial deployment. Then I get the same error message as before in eb-activity.log, and I also get this message on the Health overview:
Incorrect application version "app-2a3d-170409_214923" (deployment 1). Expected version "app-2a3d-170409_214923" (deployment 1).
Which is very strange because those two versions referenced are the same versions. I don't know what this means!

I found a solution.
Remove all you container_commands from .ebextensions/
Go ssh to instance, kill process with.
sudo killall python
Then Deploy new version without container_commands.
And start debuging all your container_commands, one by one on ssh..
Have fun.

Related

Why is shadow-cljs returning this error message on "Stale Output"? How to guarantee the watch for this building is running?

I am new to Clojure and not a pro in Javascript. I am watching the free part of the course on Reagent.
Following the instructions on the course's repo, after doing the git clone and the npm install, the author indicates running $ npm run dev. Everything seems to work fine. I can see the app on my http://localhost:3000/.
The favicon with the app's logo and its name is loaded on the corner of the browser's tab:
However, on the bottom of the web page, there is this error message from shadow-cljs:
shadow-cljs - Stale Output! Your loaded JS was not produced by the
running shadow-cljs instance. Is the watch for this build running?
Why is this happening? How should I fix it?
How to guarantee that the watch for this building is running?
Is there a simple command to run on terminal to check this?
Obs. 1: If this is relevant, my operational system is NixOS and this is my config file.
Obs. 2: I am not sure if this question is connected to my previous question on npm and Cider (Emacs IDE for Clojure) that happened while working with this same repo.
It is likely that this is due to you running npm run dev AND cider-jack-in.
I don't use emacs, so I'm not exactly sure what cider-jack-in does, but I believe it launches a new JVM. Since the npm run dev also did that you end up with two running JVMs, which also means two running shadow-cljs instances. That is not ideal and they will start interfering with each other leading to errors such as yours.
So, either you run npm run dev and use emacs to connect to that server. cider-connect or whatever is called should do that.
Or you don't run npm run dev at all and instead only cider-jack-in and then start the watch from the REPL.
Don't forget to first kill all java processes that might be running for that project. As long as there is more than one shadow-cljs process running for the project things will be weird.
This happens to me when I clicked on the build link BEFORE it has compiled. In which case, the link is displaying a previously compiled version, not the live version, and "watch" on code changes doesn't work either. Just wait for your terminal output to say "compiled" before clicking on the link.

Heroku cannot detect my node buildpack for app, but when setting buildpack in cli it says the heroku/nodejs is already set up on app?

I have tried deploying app through heroku through cli and through linking git repo, through the git repo I am now getting
! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
Detected build packs: Python, Node.js
However, when I try to uninstall python build pack as explained here (https://devcenter.heroku.com/articles/buildpacks) it says it can't be detected. When I try to install Node build pack it says it cannot be detected. But when I press deploy branch it runs the python pack since it is apparently the first build pack in the list.
I have tried making a requirement.txt file as noted in other answers but that took me from error in the post title to the error listed above with multiple packs

Errors Uploading to CircleCI with MySQL Database - Maven Clean Also Creates Issues When Run Before Maven Test

I'm using the Hibernate framework along with Maven in IntelliJ. I'm creating a MySQL database, I also have some ORM classes that map the MySQL database, and then I'm running some JUNIT tests to make sure everything works.
Where I'm having trouble is in two places, which are related to each other:
When I run mvn test, sometimes my JUNIT tests work fine and are
able to query the simulated database, establish a connection (even
though it's just with the simulated database), execute a statement,
etc. However, sometimes, if I run mvn clean before running mvn test,
while the JUNIT tests still execute, the tests output with failures
(not errors, just failures, thought this is still bad, of course).
The problem outlined in #1 is essentially duplicated when I upload to GitHub and run CircleCI (which isn't surprising, since CircleCI runs mvn test when doing its integration testing). Most of my uploads failed, but one of them finally worked. However, I'm not exactly sure why the "final" upload was successful while the others weren't.
The error messages I'm getting either from mvn test or the CircleCI builds are typically as follows. These errors are from my pent-ultimate upload, the one I did just prior to the next upload which actually worked:
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
com.mysql.cj.exceptions.CJException: Public Key Retrieval is not allowed
java.sql.SQLNonTransientConnectionException: Could not create connection to database server
I should also note that my intention is to run mvn clean first, then upload to CircleCI, however, running mvn clean seems to be somehow involved in perpetuating these errors.
As far as different resources I'm using go, here they are. If I'm forgetting something, please let me know and I should be able to include it.
In my hibernate.cfg.xml file, I have the following lines:
<property name="connection.url">jdbc:mysql://localhost:3306/stocks</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
At the end of the word "stocks" on the first line, I have sometimes appended any of the following (sometimes I only appended one of the following, other times I combined them, depending on the error(s) from either Maven or CircleCI). Appending some combination of these lines seemed to help get things to work, but running mvn clean seemed to halt any effect these additions were having:
autoReconnect=true
useSSL=false
allowPublicKeyRetrieval=true
Running the JUNIT tests from within IntelliJ usually works, but if I run mvn clean first, then IntelliJ usually won't work, unless I then go back into this file and append ?autoReconnect=true&useSSL=false. If I do that, then IntelliJ will run the JUNIT tests fine.
In my config.yml file for CircleCI, I have the following code. Certain statements were added in MAVEN_OPTS based on other research I did to try to counteract the errors I was getting, but I don't know if these statements are having any impact one way or the other:
# Java Maven CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
- image: circleci/mysql:latest-ram
environment:
- MYSQL_ROOT_PASSWORD: (my real password goes here)
- MYSQL_DATABASE: stocks
- MYSQL_USER: bob
- MYSQL_PASSWORD: (the real password goes here)
working_directory: ~/repo
environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
steps:
- checkout
- run: sudo apt install -y mysql-client
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: mvn dependency:go-offline
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
# run tests!
- run: mvn integration-test
If anyone has any idea what's going on, I appreciate the help. My goal is to be able to upload to CircleCI by first running mvn clean so only the src files, pom.xml file, and .circleci folder are included in the upload. Also, not to belabor the point, but my most recent upload to CircleCI did in fact work, but I'm not sure what made that build work while all the others ones did not.

Error in AWS ElasticBeanStalk python 27 application that was running fine

I had an py27 application running on aws ElasticBeanStalk for over a year. Recently it stopped working. So I tried to redeploy. During redeploy I got the following error in the logs:
Return code: 1 Output: [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/03deploy.py]
command failed with error code 1:
/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py
New python executable in /opt/python/run/venv/bin/python27
Not overwriting existing python script /opt/python/run/venv/bin/python
(you must use /opt/python/run/venv/bin/python27)
Can somebody tell me where I will find /opt/python/run/venv/bin/python? How can I change it to
/opt/python/run/venv/bin/python27?
Thanks
When you redeployed, you opted into the latest beanstalk version, which uses a different AMI than the one originally used. If you're familiar with the concept of ebextensions then you're probably looking to add a file like this:
.ebextensions/python.config:
ln -s /opt/python/run/venv/bin/python27 /opt/python/run/venv/bin/python

Upgrading to Ansible 2.0 with Digital Ocean api v2 Issues

I have a working vagrant + ansible setup to provision my digital ocean, it was running on api v1, but when DO deprecated it I got an error message telling me there was no support for v1 anymore. After a research I found out I needed to upgrade to ansible 2.0 + update my digital_ocean.py since the older one was still using client_id and api_key, the new one however now uses the api_token.
Basically I've updated
1.digital_ocean.py which I got from ansible repo module
2. digital_ocean.ini to contain the api_token
3. updated my api token from DO to make sure it's using the new one
but when I execute my ansible playbook I initially got this error
ERROR! The file provisioning/inventory/staging/digital_ocean.py looks like it should be an executable inventory script, but is not marked executable. Perhaps you want to correct this with `chmod +x provisioning/inventory/staging/digital_ocean.py`?
So naturally had to chmod +x it but when I did I get a new error which is
ERROR! The file provisioning/inventory/staging/digital_ocean.py is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this with `chmod -x provisioning/inventory/staging/digital_ocean.py`.
ERROR! Inventory script (provisioning/inventory/staging/digital_ocean.py) had an execution error:
ERROR! provisioning/inventory/staging/digital_ocean.py:3: Error parsing host definition ''''': No closing quotation
The next one seem to be json parsing related, my only problem is that it's on line 3 which if you check on the code itself are still on the comment side
https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/digital_ocean.py
I received both errors mentioned and solved them with the following:
The dopy related error was due to the fact that my python and pip were installed differently. dopy was installed via pip which was installed via homebrew. I was using the system python. When I installed python via homebrew, the script found dopy just fine.
Regarding the second error, that is the result I got when not setting the DO_API_TOKEN. I set mine in the command itself with:
DO_API_TOKEN=<api_token> ansible -i digital_ocean.py all -m ping