Is it possible to run a single Rails team on Heroku without a "hero launch console"?

I often need to run the “Rails.cache.clear” command on Heroku, and the only way I found this is to start the “heroku launch console” first and then run the command. Any way to do this in one step?

+6
source share
4 answers

It works:

echo "Rails.cache.clear; exit" | heroku run console 

Without a way out, it seems that for some reason it hangs, at least for me.

+10
source

I think this is what you are looking for:

 heroku run rails runner -e production Rails.cache.clear 

If you do not configure the environment, development will be used.

If this is a common task, such as flushing the cache, complete the rake task.

+8
source

Create a rake command with the command. For example, the file lib / tasks / cache.rake

 namespace :cache do desc 'Clear memcache' task :clear => :environment do Rails.cache.clear end end 

Then you can run the command

heroku run rake cache:clear

+4
source

I understand that I could be wrong, but heroku run console && Rails.cache.clear ? Make it a small script file (say herokuclear ) and set it to PATH, maybe?

0
source

Source: https://habr.com/ru/post/926694/


All Articles