heroku cedar console - heroku

I've been trying to get a heroku console session going on cedar and am having no joy.
The old way was:
heroku console
I understand the new way involves 2 steps:
heroku run bash
then
$ rails console
but at the heroku run bash stage i keep geting:
heroku run bash
Running `bash` attached to terminal... up, run.1
!
! Timeout awaiting process
so i checked there isn't a port blocking issue and
telnet rendezvous.heroku.com 5000
gives
Trying 50.19.103.36...
Connected to ec2-50-19-103-36.compute-1.amazonaws.com.
Escape character is '^]'.
which is as expected i think
what am i doing wrong and what do i need to do to get this console up and running?
Thanks!
PS I have tried - heroku run console - also, and that times out too.

In cedar every command that needs to be attached to terminal uses run.
ex:
heroku run console
heroku run rake db:migrate
When its not necessary to be attached don't use the run:
ex: heroku logs

The new way is heroku run console

Ok - it was obvious after a few hours of sleep. Simply had to update the heroku gem that had got corrupted somehow on my mac. If you have something like this problem, then do that first...

Related

How to run auto restart in heroku for ruby scripts

In my Dev box on Nitrous, I am able to run God -c scripts.god -D to restart the two .rb files if they die.
I just run that and the processes for the most part stay alive.
But I cannot do the same in heroku. It seems when I run the god command the .god file does not open and generates an error in heroku.
Question:
How can I run God to restart failed processes in heroku as I do on my development Nitrous environment?
Or is there a recommended alternative way to watch heroku processes and restart them automatically when they fail?
On Heroku you shouldn't need to use a process supervisor like god. If all you need is to ensure your process is restarted if it crashes, Heroku can manage that fine.
It should be as simple as adding two entries in your procfile as workers. https://devcenter.heroku.com/articles/background-jobs-queueing
worker: bundle exec sidekiq
clock: bundle exec clockwork lib/clock.rb
slack_listener: bundle exec ruby lib/slack_bot.rb
You could possibly have issues, if your processing are crashing quite often. Dyno Crash Restart Policy
Your processes should start automatically when you access your website.
However, Heroku does provide commands to manage your processes, check out https://devcenter.heroku.com/articles/dynos for the complete list. E.g., to restart all processes, use the toolbelt command:
heroku ps:restart --app yourappname

"heroku ps" shows no processes running

Seems like a simple question, but I haven't found the answer anywhere. Running heroku ps shows nothing. heroku restart executes successfully.
Have you tried scaling one of your process types? e.g. heroku ps:scale web=1
See https://devcenter.heroku.com/articles/scaling
I was doing a silly mistake. I was using
heroku run ps (since there were other commands that I was using as "run")
instead of
heroku ps. (ps is a heroku command and not a system command).
Removing run fixed the issue. Thanks.

Heroku Cedar Stack and command heroku run console

In my old Ruby 1.9.2 Sinatra apps running on Bamboo stack, heroku console provided a shell that not only initialized Active Record but also logged to a history file in my .heroku directory.
After moving to Heroku Cedar stack and using Ruby 1.9.3, I found heroku run console did not load any of my Active Record models. I fixed that by writing a small ruby script to initialize Active Record and load my models.
I execute this using the awkward heroku run 'bundle exec irb -r ./console'
This IRB console fires up fine and gives me access to my model data, but no history is logged.
1) Why is heroku run console so neutered?
2) How can I get my console sessions to log to history?
Please?
Thanks
Add the following line to your Procfile:
console: bundle exec irb -r ./console
Keeping the history is not easily possible, as it will spin up a dyno for every new invocation (cedar stack doesn't keep the history for Rails console, either). You could try using rlwrap to keep your history on the local machine.
From the docs:
You can use heroku console as a stand-in for Rails’s script runner, to
run one-time commands directly from the command line
and
Without an argument, heroku console launches an interactive console
similar to irb or the Rails script/console command
run console is aimed at running the Rails console, or irb.

Why can't I start a Heroku console on the Cedar stack?

Trying to debug a new Heroku deployment - seems to be missing a db table. To do this, I'm running heroku run console but I get back :-
Running console attached to terminal... up, run.7
sh: console: not found
under both my Linux and Windows environments
What have I missed to get this working?
[Very late update : this is for a Java Heroku app, not a RoR one, so anything related to rails is a little lost on me]
on Celadon Cedar Stack it is changed to:
$ heroku run bash
$ heroku run bash
then
…#…:/app$ script/rails console
It worked for me. Though the second step is specific to Ruby on Rails – I don’t know the equivalent commands for other platforms and frameworks.
To run rails console, it's just:
heroku run rails console

Killing abandoned process on Heroku

I killed an IRB prompt in a not-so-graceful manner (started with heroku run irb), and now I've got a zombie process which I can't seem to kill:
Process State Command
------------ ------------------ ------------------------------
run.3 up for 2h irb -r ./init.rb
web.1 up for 0s thin -p $PORT -e $RACK_ENV -R $HER..
I've tried:
heroku restart
heroku ps:scale run=0
heroku ps:restart run.3
Anyone know how I can force quit it?
I noticed a new ps:stop command added to the Heroku command line client a few days ago:
https://github.com/heroku/heroku/commit/a6d9eb7f314bf2c5f162a508e8d764286fb577bb
I'm not sure if that change made it into version 2.9.0 but it would be worth a try.
Update
This is now in the Heroku Toolbelt. Just run:
heroku ps:stop <process id from heroku ps>
Example:
heroku ps:stop run.8729
Thanks James!! I needed to update my Heroku client first, and it worked like a charm.
$ sudo gem install heroku
$ heroku ps #to view processes
$ heroku stop <process name here>
edit: they've fixed this issue
Heroku doesn't have a way to kill abandoned run.x processes.
But it will be killed automatically after 24 hours.
If anyone else is struggling with killing using something like:
heroku run ps:stop run.789
Killing by id worked for me:
heroku ps:kill 61ff0687-eaf4-4299-9c65-f0b22af7ec67
I got the id using the platform api list dynos - https://devcenter.heroku.com/articles/platform-api-reference#dyno-list
Worked for a detached one-off that was abandoned.

Resources