Application Error after deploying Meteor 1.0 app on heroku - mongodb

I'm trying to deploy a meteor.js app (v 1.0) on heroku using the following buildpack:
https://github.com/AdmitHub/meteor-buildpack-horse
and following along this tutorial:
http://www.growthux.com/ux-html-css-js-growth-hack/installing-meteor-on-heroku
My app is more like a static website, i'm using the database to build a simple back office:
- storing the admin user and image paths which are then dynamically rendered in my templates.
After having created my app on Heroku, set ROOT_URL variable, set the MONGO_URL= variable to my external db on MONGO HQ, (tried mongo lab as well, same problem) and finally push to Heroku, i'm getting this error message when I visit the url:
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
So I did:
2014-11-10T17:10:23.825922+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-11-10T17:10:23.825723+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-11-10T17:10:24.584852+00:00 heroku[web.1]: State changed from starting to crashed
2014-11-10T17:10:24.574995+00:00 heroku[web.1]: Process exited with status 137
2014-11-10T17:10:26.415257+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cle-meteor.herokuapp.com request_id=ffc312a1-316d-4337-9165-caa492aa7c15 fwd="80.13.242.126" dyno= connect= service= status=503 bytes=
Not sure if I did something wrong regarding the deployment process, or if I must rethink how my app interact with the database when not running locally.
Any insights?

I had a similar issue, it turned out that I'd left off the "http://" from the ROOT_URL.
Your log messages are fairly generic, is there anything before that?
Here's how I got the meteor "todos" app running on heroku and mongolab.
Meteor on Heroku
Install meteor
curl install.meteor.com | /bin/sh
Add meteor to our path so we can run the "meteor" command from anywhere.
clone an existing meteor app into the heroku folder.
meteor create --example todos heroku
change to the meteor app's folder.
cd heroku
I added a package.json file that looks like the following.
{
"name": "myapp",
"version": "0.0.1",
"engines": {
"node": "0.10.33",
"npm": "1.4.23"
},
"dependencies": {
"fibers": "1.0.0"
}
}
change to our home folder. We want to come back to our previous spot.
pushd ~
get the heroku client and install it.
wget http://assets.heroku.com/heroku-client/heroku-client.tgz
tar -zxvf heroku-client.tgz
export PATH=${PATH}:${HOME}/heroku-client/bin
Go back to our previous location.
popd
login to heroku.
heroku login
SKIP THIS PART IF YOU ALREADY HAVE SSH CONFIGURED NICELY WITH HEROKU AND GITHUB
Add your public SSH key to heroku (if you haven't already done so)
heroku keys:add ~/keys/heroku_public_key_ssh.txt
(Manually) Ensure that public SSH key has also been added to your GitHub account.
If you're running ssh-agent, ensure your matching private SSH key is loaded
ssh-add ~/.ssh/id_rsa_heroku_github
Set up our subfolder as a git repository, which we will push to heroku. Substitute your own heroku app name for "mikestodos" below.
git init
heroku git:remote -a mikestodos
git add .
git commit -a -m "first deploy"
Create a heroku app. Mine is called mikestodos.
heroku create mikestodos --stack cedar --region us --buildpack https://github.com/AdmitHub/meteor-buildpack-horse.git
Create a new mongolab database, and a new database user as well.
Set the MONGO_URL for heroku to be our MongoLabs database URL. The format is:
heroku config:set MONGO_URL=mongodb://<my_mongouser>:<my_mongodbpassword>#<mymongoserver>:<mymongoport>/<mymongodbname>
substitute your own MongoLabs URL below.
heroku config:set MONGO_URL=mongodb://mikestodos:<dbpassword>#ds051980.mongolab.com:51980/mikestodos
Set the ROOT_URL for our heroku app.
heroku config:set ROOT_URL=http://mikestodos.herokuapp.com
Now push our app to heroku.
git push heroku master

Related

Scala, Akka Http, Heroku in sbt multi-project

I'm starting with Heroku, I'm a developer that build Rest API using Scala and Akka Http.
Yesterday I was able to create a very simple API and deploy it in Heroku. To do I followed this example: https://dzone.com/articles/akka-http-from-zero-to-heroku-in-10-minutes
Then I decide to add complexity to the API so I created a new project: an sbt multi-project. Usually I do pretty much what is described in this example: https://pbassiner.github.io/blog/defining_multi-project_builds_with_sbt.html. The code of this project is located here: https://github.com/ovats/heroku-akka-multi.
In my local environment the project works fine. I start the service with:
sbt api/run
Then using curl I can make a request:
curl http://localhost:8080
So far so good.
The problem is: I can deploy it to Heroku (git push heroku master) but it wont run.
Using the heroku cli I can see in the logs:
...
2021-11-27T01:06:44.368868+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/heroku-akka-multi`
2021-11-27T01:06:46.211834+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-11-27T01:06:46.211994+00:00 app[web.1]: bash: target/universal/stage/bin/heroku-akka-multi: No such file or directory
2021-11-27T01:06:46.339690+00:00 heroku[web.1]: Process exited with status 127
2021-11-27T01:06:46.472410+00:00 heroku[web.1]: State changed from starting to crashed
2021-11-27T01:06:46.475832+00:00 heroku[web.1]: State changed from crashed to starting
...
Ok, I can see bash: target/universal/stage/bin/heroku-akka-multi: No such file or directory. I think this is related to the content of the file Procfile.
Is the problem the Procfile content?
Is the issue somewhere else?
It seems that Heroku does not know how to start the service, maybe where is the main class or something similar to this. What am I doing wrong?
Any help will be appreciated.

How to reset the DB on each deployment on heroku?

So currently I'm working on a project on Heroku with Drupal and my issue is that I want to reset the database each time I deploy to master, yes I know it not ideal but its a development env because I'm working Drupal plugin and it would be nice if changes happened it could just reset to a state.
But when I try to connect using psql and some variables I just get password authentication failed for user even tho I know its the right password because I got it from Heroku itself.
Currently, I have tried using the console to try to make in connection soi could run a DROP TABLE command for me to afterword import an SQL file with the basic setup using pg_dump, and put it into a .sh script and run it with and release: in a procfile
Until now I have this as a release.sh file where I only tried in the console on heroku
PGHOST=HOST PGPORT=5432 \
PGDATABASE=DB \
PGUSER=USER PGPASSWORD=SOMEPASS \
psql
Try below command to reset DB
heroku pg:reset DATABASE_URL

Deploying a meteor app using mongoLab and Heroku sandbox

I've checked a couple of blogs. Specially this one about deploying and hosting meteor on heroku using mongolab.
I follow the steps below:
Create a meteor app (just for test v.1.4) meteor create test
cd test
git init
git add .
git commit -m "tst"
heroku create pikachu
heroku config:set ROOT_URL="https://pikachu.herokuapp.com"
heroku config:set MONGO_URL="pikachu:este#dsxxx.mlab.com:xxx/pikachueste"
heroku buildpacks:set https://github.com/Pushplaybang/meteor-buildpack-horse
git push heroku master
After deployment the following error appears:
Starting process with command .meteor/heroku_build/bin/node .meteor/heroku_build/app/main.js
Process exited with status 8
assert.js:93
throw new assert.AssertionError: "undefined" === "function"
at wrapPathFunction(/app/.meteor/heroku_build/app/programs/server/mini- files.js:77:10)
at Object.<anonymus>(/app/.meteor/heroku_build/app/programs/server/mini-files.js:108:24)
...
Process exited with status 8
State changed from starting to crashed
I've notice that when I try to install mongodb addon in my sandbox:
heroku addons:create mongolab:sandbox
The process finish with:
!Please verify your account to install this add-on plan ...
Does the problem occur because I cannot install mongodb addon?
Is it possible to install mongodb addon in a heroku sandbox?
Is there any other alternative?
Thanks,
one of the reasons for this error:
assert.js:93
throw new assert.AssertionError: "undefined" === "function"
at wrapPathFunction(/app/.meteor/heroku_build/app/programs/server/mini- files.js:77:10)
at Object.<anonymus>(/app/.meteor/heroku_build/app/programs/server/mini-files.js:108:24)
Is that the node version being run on heroku is different from the one meteor is using. So far, Meteor is using node v.4.5.0 and the one your buildpack is using is below that. I've used that buildpack once and had the same error.
You can use the original meteor buildpack horse and deal with the
Please verify your account to install this add-on plan ... by removing the mongolab addon. I experienced these issues myself. You can refer to this guide so it can be much clearer to you. It uses a fork of the original meteor buildpack horse without the mongolab addon. Just follow the guide and you'll be fine.

Heroku transfer db from one app to another

I need to transfer db from app_1 to app_2
I created backup on app_1
Then ran:
heroku pg:backups restore HEROKU_POSTGRESQL_COLOR --app app_2 heroku pgbackups:url --app app_1
HEROKU_POSTGRESQL_COLOR = database URL for app_2
Then I get:
! `pg:backups` is not a heroku command.
! Perhaps you meant `pgbackups`.
! See `heroku help` for a list of available commands.
So I ran:
heroku pgbackups:restore HEROKU_POSTGRESQL_COLOR --app app_2 heroku pgbackups:url --app app_1
Then I get the following:
! WARNING: Destructive Action
! This command will affect the app: app_2
! To proceed, type "app_2" or re-run this command with --confirm app_2
So I confirmed with:
> app_2
! Please add the pgbackups addon first via:
! heroku addons:add pgbackups
So then I ran: heroku addons:add pgbackups --app app_2
Adding pgbackups on app_2... failed
! Add-on plan not found.
Is there a way around this issue? any help would be greatly appreciated!
* Solution *
I ended up emailing Heroku, they advised that I need to heroku update; heroku plugins:update but heroku update is only available to heroku toolbelt only and I had the gem installed.
Solution:
Install Heroku toolbelt here
Then uninstall the gem:
gem uninstall heroku --all
run the following to get the version and it should output heroku-toolbelt, instead of the gem, more info here
$ heroku --version
heroku-toolbelt/2.39.0 (x86_64-darwin10.8.0) ruby/1.9.3
To copy the databases over:
heroku pg:backups restore `heroku pgbackups:url --app app_1` HEROKU_POSTGRESQL_COLOR --app app_2
But even better—you can copy directly from one database to another without needing the backup:
Assuming app_2 database url is: HEROKU_POSTGRESQL_GOLD
heroku pg:copy app_1::DATABASE_URL GOLD -a app_2
That will copy the main database from app_1 to the GOLd database on app_2
its only 1 command to copy database from app to app now you don't have to backup:
heroku pg:copy app_name_to_copy_from::database_color_to_copy_from database_color_to_copy_to --app app_name_to_copy_to
check it here
If you look at heroku docs it says
PG Backups as an add-on has been deprecated. The commands exist as part of the Heroku Postgres namespace in the CLI. The new functionality is live and available for use.
So you can use the pgbackups functionality directly without having to add any add-ons
To create a backup you can run
heroku pg:backups capture --app app_name
if you have multiple databases then you can specify database url like this
heroku pg:backups capture HEROKU_POSTGRESQL_PINK
To restore from a backup on another app you can run
heroku pg:backups restore b001 DATABASE_URL --app app_name
You can transfer database by
heroku pg:copy DATABASE_URL HEROKU_POSTGRESQL_PINK_URL --app app_name
You can also upload your database to a public url and then use that url to import database on another app by
heroku pg:backups public-url b001 --app app_name
and then import it by
heroku pg:backups restore 'https://s3.amazonaws.com/me/items/3H0q/mydb.dump' DATABASE -a app_name
If you are moving from one app to another and want to use same database for another app then you can follow these steps:
Login to your heroku account
Select your old app and go to settings tab
Reveal config vars for your old app
Copy DATABASE_URL
Go back and select your new app
Replace new apps DATABASE_URL with the old apps value
I needed something slightly different so sharing it here:
heroku pg:copy name_of_app_being_copied::DATABASE_URL DATABASE_URL --app name_of_app_being_copied_to
Note: Both references to DATABASE_URL do not need to be changed. It may seem odd, but the first instance references the database url for the app being copied and the second one references the database url of the app being copied to.
heroku pg:copy app1_name::HEROKU_POSTGRESQL_ONYX_URL HEROKU_POSTGRESQL_AQUA_URL --app app2_name
Where the second db url is on app2_name
There are simple ways to do this, and there is a fast way to do it
The simple ways generally involve using a backup/restore methodology (including pg:copy, which is a backup that streams the data directly to a pg_restore process), but these are slow in creating the new database because you are restoring a logical definition of tables, loading the data, and creating indexes on the data.
That's a lot of work, and for my 30GB standard-2 databases it can literally take hours.
The fast way to do it is to provision a follower of the database to be copied (e.g. production) on the application you want the data on (e.g. test). On the same 30GB databases that take hours to do a restore, this last took about 15 minutes.
The methodology I use is:
# Get the name of the source database addon (e.g. postgresql-clean-12345)
heroku pg:info -a production-app
# Create a follower on the destination app (choose your own plan)
# You create the follower on the new app because otherwise it is
# perpetually associated with the source as it's "billing app"
heroku addons:create heroku-postgresql:standard-2 --follow postgresql-clean-12345 -a test-app
heroku pg:wait -a test-app
# Quiesce the destination app
heroku scale web=0 worker=0 -a test-app
heroku maintenance:on -a test-app
# Get the colour of the new database (e.g. HEROKU_POSTGRESQL_GRAY_URL)
heroku pg:info -a test-app
# Unfollow the source database.
# If you want to upgrade the database, do that now instead of the
# unfollow.
heroku pg:unfollow HEROKU_POSTGRESQL_GRAY_URL -a test-app
# Promote the new database on the destination app
heroku pg:promote HEROKU_POSTGRESQL_GRAY_URL -a test-app
# Get the colour of the old database, if any(e.g. HEROKU_POSTGRESQL_MAROON_URL)
heroku pg:info -a test-app
# Destroy the old database (if any)
heroku addons:destroy HEROKU_POSTGRESQL_MAROON_URL -a test-app
# Bring the test app back up
heroku scale web=1 worker=1 -a test-app
heroku maintenance:off -a test-app
Why is this faster?
I believe that when creating a follower, Heroku creates the new database by either copying data files or restoring from a physical (file) backup, then replaying the logs to bring it up to date.
I found the simpler solution to reuse/share the same resource (postgres database in this case - or any others that allow sharing/reuse) with more than one app on heroku is doing the following:
Go to the older (source) app dashboard on Heroku
Select the "Resources" tab
Locate the resource (postgres database, in our case here)
Click on the icon next to the plan name at the right most part of the row listing the resource
Select the "Attach to another app" option and select the newer (target) app name from the list that shows up
Sample of the extended menu mentioned # step #4 above!
That's all it takes to share the resource between the apps as it automatically updates all the related configuration settings on the target app. This comes handy since none of the add-on related configuration variables are directly editable, at least from the dashboard (have not checked through the CLI). Hope this helps anyone looking for similar thing.
As per the website the addon is depreciated. So that could be the reason for the failure message.
Backups as an add-on has been deprecated.
Since your aim is to move the db from one app to another, why don't you try the instructions mentioned in the link below.
https://devcenter.heroku.com/articles/heroku-postgres-backups#direct-database-to-database-copies
heroku addons:create heroku-postgresql:standard-0 --fork postgresql-translucent-12345 --app target-app
Where postgresql-translucent-12345 is the addon name of the database you want to fork from. Note that the color url does not work across different apps but the addon name does.
You can also add the "--fast" option:
heroku addons:create heroku-postgresql:standard-0 --fork postgresql-translucent-12345 --fast --app target-app
Which creates a fork of the database that could be up to 30 hours old. Even without the fast option, I copied a 40GB database in 10 minutes-ish.
https://devcenter.heroku.com/articles/heroku-postgres-fork
Then you have to, of course, promote the database. See David Aldridge's answer -and my comments- above for some further details about the process.
I had a related issue. You can save a backup to your local machine, then upload it to some hosting, like amazon s3, and import from given url.
This question and following answer may help you: Can't import to heroku postgres database from dump
You may find useful pgAdmin III (http://pgadmin.org/), a free db management tool specifically designed to do these types of tasks. You can edit/view/import/export from/to your Heroku db directly. Let me know if you need help in setup. (It's like MySQL Workbench, but for PostgreSQL).

How can I restart my openshift postgres cartridge?

My app has fallen over as it can't connect to the postgres DB and when I try to connect to the DB via ssh and psql I get the following message:
psql: could not connect to server: Connection refused
Is the server running on host "<GEAR_ID>-<NAMESPACE>.rhcloud.com" (<IP_ADDRESS>) and accepting
TCP/IP connections on port <PORT_NUMBER>?
Running rhc app show --state prints:
Cartridge jbossas-7, haproxy-1.4 is started
Cartridge postgresql-9.2 is started
also, running rhc app show shows nothing unusual.
I can't telnet to the above IP_ADDRESS & POST_NUMBER, which kinda looks like communication has been broken between the 2 gears.
Any ideas?
I had the same problem. Using pg_ctl instead of the rhc commands fixed it for me.
$ rhc ssh <appname>
[...rhcloud.com ...]\> pg_ctl restart
pg_ctl: old server process (PID: 20034) seems to be gone
starting server anyway
server starting
To restart your entire application:
rhc app restart <app_name>
TO restart just your postgresql cartridge:
rhc cartridge restart <cart_type> --app <app_name>
You can get the cart type by running
rhc app show <app_name> --gears
And looking for the cartridge name under the "cartridges" heading
Ok, so I managed to work around this issue but man it was a PITA.
Since I couldn't find any useful help on the web around this problem, I've ended up creating a new app based on my old one, and using pg_dump and psql to save and restore the db from the old application into my new app.
I'm still none-the-wiser as to why the original app was no longer able to communicate from the main jboss gear to the postgresql gear, even though the postgres server was up and running.
Perhaps (hopefully) someone from openshift will want to look into this. If so I'll keep my old broken app around for a while.