Some useful commands. You should always use them to check the status of your app before you want to modify anything. First is to check the basic information of your app in the root dir:
This lists the name, add-ons, database, etc. Give you a general look.
Second is to check all your processes for this app, or as heroku calls, dynos. There are two types of dynos, web dyno, which dealing with web request; work dyno, dealing with your assignment/scheduled jobs for your app. More web dynos means better performance and faster respond when there are a lot of requests to your app; more work dynos should facilitates your work (IMO). When you create a web app on heroku it automatically assign one web dyno for you for free. After that, they will approximately charge you $35/mo for 1 additional dyno. You could see I only assign 1 web dyno for my app:
Third is to check the log of your web app, see what did it do:
Then we have heroku keys/apps/addons to check our ssh keys, all available apps and add ons for this particular app respectively. in general, it is easy and convenient to check basic information of your apps using heroku CLI tool.
Now for the django project, tutorial gives details so I will not repeat it. Just a problem I come across: work with local database using postgreSQL.
As mentioned in the tutorial, we should use postgreSQL as the production database and actually when we create the app heroku automatically create that db for us. The problem is how to make the app know this is the db it should use. Tutorial use the dj_database_url package which sadly not work for me. I find this postgresify very easy to use. It only needs two steps to set the production db:
Now we have the production db but how about local development db? The postgresify seems will not detect default one. When I use it alone I get various error. According to this post, turns out I have to override the production db into local db if django finds it is in the development environment. I use the code form the post and it works finally.
Until now I still cannot restore my site on heroku; it might take longer time.
(your_virtualenv_name)your_device:hellodjango your_username$ heroku info === afternoon-sword-7524 Addons: Shared Database 5MB Database Size: 296k Git URL: git@heroku.com:afternoon-sword-7524.git Owner Email: your_email Repo Size: 85M Slug Size: 12M Stack: cedar Web URL: http://afternoon-sword-7524.herokuapp.com/
This lists the name, add-ons, database, etc. Give you a general look.
Second is to check all your processes for this app, or as heroku calls, dynos. There are two types of dynos, web dyno, which dealing with web request; work dyno, dealing with your assignment/scheduled jobs for your app. More web dynos means better performance and faster respond when there are a lot of requests to your app; more work dynos should facilitates your work (IMO). When you create a web app on heroku it automatically assign one web dyno for you for free. After that, they will approximately charge you $35/mo for 1 additional dyno. You could see I only assign 1 web dyno for my app:
(your_virtualenv_name)your_device:hellodjango your_username$ heroku ps === web: `gunicorn hellodjango.wsgi -b 0.0.0.0:$PORT` web.1: up for 39m
Third is to check the log of your web app, see what did it do:
(your_virtualenv_name)your_device:hellodjango your_username$ heroku logs ... 2012-06-18T20:23:33+00:00 heroku[web.1]: State changed from starting to up 2012-06-18T20:23:35+00:00 heroku[web.1]: Process exited with status 0 2012-06-18T20:23:42+00:00 heroku[run.1]: State changed from created to starting 2012-06-18T20:23:44+00:00 heroku[run.1]: Starting process with command `python manage.py syncdb` 2012-06-18T20:23:44+00:00 heroku[run.1]: Awaiting client 2012-06-18T20:23:45+00:00 heroku[run.1]: State changed from starting to up 2012-06-18T20:23:47+00:00 heroku[run.1]: Process exited with status 0 2012-06-18T20:23:47+00:00 heroku[run.1]: State changed from up to complete ...
Then we have heroku keys/apps/addons to check our ssh keys, all available apps and add ons for this particular app respectively. in general, it is easy and convenient to check basic information of your apps using heroku CLI tool.
Now for the django project, tutorial gives details so I will not repeat it. Just a problem I come across: work with local database using postgreSQL.
As mentioned in the tutorial, we should use postgreSQL as the production database and actually when we create the app heroku automatically create that db for us. The problem is how to make the app know this is the db it should use. Tutorial use the dj_database_url package which sadly not work for me. I find this postgresify very easy to use. It only needs two steps to set the production db:
from postgresify import postgresify DATABASES = postgresify()
Now we have the production db but how about local development db? The postgresify seems will not detect default one. When I use it alone I get various error. According to this post, turns out I have to override the production db into local db if django finds it is in the development environment. I use the code form the post and it works finally.
Until now I still cannot restore my site on heroku; it might take longer time.
No comments:
Post a Comment