Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run rake in ruby-on-rails application in production?

I am trying to figure out how to deploy my ruby-on-rails application in production.

The operating system is ubuntu and the application uses Postgres. I have managed to deploy the application and am able to login etc... but there are certain functionality that is not working (I am new to the application and rails). The application uses elastic search, which I have installed and the service is running (I can access the page via http://localhost:9200). But when the application tries to access components of elastic search i get an error.

There is a rake file in the directory /app/lib/tasks, which has several files and one of the them is elasticsearch.rake

namespace :app do
  desc "Bootstraping Elasticsearch index"
  task(:elasticsearch => :environment) do

    Image.__elasticsearch__.create_index! force:true
    Image.import

    CaseStudy.__elasticsearch__.create_index! force:true
    CaseStudy.import

  end
end

As the description in the file says this bootstraps the elastic search index.
What I don't know is how do I run all this in a production environment? There are other rake files as well and I want to know how to run them.

like image 671
A j Avatar asked Apr 18 '16 09:04

A j


1 Answers

You should go to the root path of your project directory in production and type the following command:

RAILS_ENV=production bundle exec rake app:elasticsearch

Note:

To check the available list of rake tasks, you can type rake -T

like image 82
dp7 Avatar answered Sep 22 '22 11:09

dp7