Last week I’ve dedicated most time to implement new heroku features to Open Event. Due to the fact that wasn’t easy tasks I can share my experience.
What is heroku?
Heroku is a cloud Platform-as-a-Service (PaaS) supporting several programming languages like Java, Node.js, Scala, Clojure, Python, PHP, and Go
Easy to deploy
what you need to do:
- Create account on heroku
- Download a heroku toolbelt to your enviroment.
- Go to your project directory(/open-event-orga-server)
- Sign in to heroku in your command line using your credentials
$ heroku login
- Create app with name $
heroku apps:create your_app_name
after execution above command you will recive a link to your application
http://your_app_name.herokuapp.com/
- Push latest changes to heroku
$ git push heroku master
- If everythings is ok you can check results http://your_app_name.herokuapp.com/ (sometimes it does not work like we want 🙁 )
Easy to configure
To list/set/get config variables use:
$ heroku config
$ heroku config:set YOUR_VARIABLE=token123
$ heroku config:get YOUR_VARIABLE
or you can go to you application dashboard and make above operations
How you can get access to this variables using python langauges?
$ python Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> your_variable = os.environ.get('YOUR_VARIABLE', None)
>>> print your_variable
token123
I’ve used this to display current release in my python application(You need to generate a special API token and add it to config variables)
os.popen('curl -n https://api.heroku.com/apps/open-event/releases -H "Authorization: Bearer ' + token + '" -H "Accept: application/vnd.heroku+json; version=3"').read()
Easy to monitor
If something is wrong with your APP you need to use this command
$ heroku logs
it shows all logs
To see 10 latest releases use:
$ heroku releases
How you can set up Open Event to deploy to heroku?
- Clone https://github.com/fossasia/open-event-orga-server
- Go to directory of open event orga server(/open-event-orga-server)
- Add git remote
heroku git:remote -a open-event
- You can check if open event is added to git remote
$ git remote -v heroku https://git.heroku.com/open-event.git (fetch) heroku https://git.heroku.com/open-event.git (push) origin https://github.com/fossasia/open-event-orga-server.git (fetch) origin https://github.com/fossasia/open-event-orga-server.git (push)
- Now you can deploy changes to open-event application(You need a permissions 🙂 )
Why should you use a Heroku?
It’s great to deploy apps because you are able to share content in short time what I’ve done. Besides it’s very well documented so you can find there answers for most of your questions. Finally most of things you can configure using Heroku dashboard so it’s the best advantages of this tool.