heroku Blogs
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
Kiprosh is now part of LawLytics
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
Sometimes dealing with DB processes in a Rails application consume a lot of time. Often there are a bunch of small and simple DB queries that go endless. For example, bulk insertions or bulk updates in tables. Dividing it into various background jobs is an idle solution. In a few scenarios, we can't prefer background jobs e.g. the change you apply, makes the existing data invalid. In this article, we will see how to complete a large set of DB queries under minutes which would otherwise take hours if not optimized. It's a better practice to create a rake
As you know Heroku **does not ** run rake db:migrate automatically. Most of the time we all face this issue of not running migrations on Heroku post deployment. Either we forget or for some reason we miss it. However there are some gems/plugins that help us overcome these issues. Even when we use [heroku auto deployment] [12] feature, there also we need to run rake db:migrate manually and Heroku will not run it automatically for us. That means it is not fully automatic. When I setup heroku auto-deployment I wanted everything to happen automatically, why should I run
While we deploy our changes to heroku, we use deployment scripts or setup yml in CI server. However Heroku has come up with an auto-deployment feature and for that we do not need to use even command line tools. To take advantage of this feature you should use Github/Bitbucket version control system If your Github/Bitbucket repo is setup and you have already pushed your code to Github then you are good to start with heroku I assume that you already have Heroku account and heroku-toolbelt is setup on your system. Now create an app on heroku for your
To Setup Heroku on local machine we first need to add the heroku gem using, gem install heroku then we need to add heroku plugins using, heroku plugins:install git://github.com/ddollar/heroku-accounts.git we then need to add heroku account using, heroku accounts:add project --auto where "project" can be any name that’s meaningful to you, the name is only used locally. We can add multiple heroku accounts using the above command, now we need to set the newly created account using, heroku accounts:set project we can use the above command to switch between
In most of our apps, we probably need to execute few background tasks more often, like every 10 minutes, once a week, etc. For scheduling these jobs, we need a scheduler that can re-run these tasks on specified intervals. There are few schedulers like whenever, resque-scheduler, rufus-scheduler, etc that can do the job. However, these gems are not compatible Sidekiq and with apps deployed on Heroku. There are 2 ways to make it work on Heroku. 1/ Using Heroku Scheduler addon. Steps: i) Create sidekiq job. ii) Create a rake task that will triggers that worker. iii) In Heroku Scheduler