How do I use phoenix console (iex) with heroku? - heroku

I'm trying to change some data on heroku that I normally do with iex -s , but the following command does nothing.
heroku run iex

The command that worked was
heroku run iex -S mix

When dealing with phoenix project just use:
heroku run iex -S mix phoenix.server
To launch the server in your iex console
or simply
heroku run iex -S mix
to compile the files without starting the server.

Note that if you deploy your app to Heroku using the native release mechanism that comes with Mix since Elixir 1.8, you may simply ssh into the running dyno and remote into the running BEAM node:
# In your local terminal
heroku ps:exec
# In the dyno
_build/prod/rel/your_app/bin/your_app remote
This works out of the box.

Related

Heroku - Run Heroku CLI commands from web dashboard

Is it possible to run heroku-cli-commands like heroku regions from the Heroku Dashboard?
I tried to run those in the console, but it did not work..
From the heroku explanation page, as well as the appearance of the console, it seems that you can only run commands that start with heroku run (Example: npm start).
That means you can run commands there for the app, and heroku will pass them to it. Like you could run if the app was running on your computer. But do not run regular heroku cli commands, for example install an add-on, through the dashboard on the website, but only through heroku cli

How to schedule PostgreSql procedure using Heroku scheduler?

I am trying to schedule PostgreSql procedure using Heroku scheduler. I tried heroku pg:psql -c "call procedure_name();" --app app-name but gets the error from scheduler "bash: heroku: command not found"
That error is telling you important information. The Heroku CLI is not present in your environment, so bash complains that heroku isn't a command that it recognizes.
If you want to run heroku commands from your application you'll need to include the cli buildpack when you build your application to make sure it's properly bundled. Once you've included the buildpack and triggered a new build, this should work.

`container:init` is not a heroku command

I have installed heroku with homebrew in my OSX El Capitan(10.11.5) and installed the heroku-container-tools with:
heroku plugins:install heroku-container-tools
The installation goes successfully:
Installing plugin heroku-container-tools... done
When I run a heroku version, I got this:
heroku-toolbelt/3.42.22 (universal.x86_64-darwin15) ruby/2.0.0
heroku-cli/5.2.20-9d094b0 (darwin-amd64) go1.6.2
=== Installed Plugins
heroku-container-tools#3.0.0
But when I run a heroku container:init I got this:
! `container:init` is not a heroku command.
! See `heroku help` for a list of available commands.
Running heroku help container I got this:
Usage: heroku container
Use Docker to build and deploy Heroku apps
Use Docker to build and deploy Heroku apps
Additional commands, type "heroku help COMMAND" for more details:
container:login # Logs in to the Heroku Docker registry
container:push [PROCESS] # Builds, then pushes a Docker image to deploy your Heroku app
I am following this heroku tutorial: https://devcenter.heroku.com/articles/local-development-with-docker
In the tutorial is said to run heroku container:init
This command was replaced but some other and heroku did not updated their documentation or I have some problem installing the plugin?
Yes, they restricted access to their container registry, just read the warning on top of the tutorial you're following https://devcenter.heroku.com/articles/local-development-with-docker
heroku container:release, which creates a Heroku-compatible slug and
deploys it to Heroku, has been deprecated. For access to our container
registry (available in private beta), please contact
docker-feedback#heroku.com
now there are only login and push commands. I hope you can easily ask for the access.

Reach heroku app terminal

I deployed an app onto heroku and wanted to check how can I connect to the deployed app in my terminal so I can do things like run migrations?
thanks in advance!
You can use the heroku command to create a one-off dyno to run arbitrary commands like bash or rake db:migrate.
For example heroku run bash -a my-app will run a bash shell on a one-off dyno.
Note that there is no way to directly connect to a running dyno on Heroku (e.g. via ssh); running the heroku run command will create a new temporary dyno that you can use to run commands using the deployed version of the code.

Running flask cli commands on Heroku

In Flask we can define CLI commands by passing it to app.cli.command
It's all fine and dandy, and I can run my initdb command on my local machine with python3 -m flask -a appname initdb
I've uploaded the app successfully to Heroku, and it's live and working except for the pages that require database interaction. My initdb command itself should already work with Heroku, with one problem, I cannot run initdb on Heroku.
Running this heroku run python3 -m flask -a appname initdb produces the output:
Usage: python -m flask [OPTIONS] COMMAND [ARGS]...
Error: No such command "initdb".
While using heroku run python3 -m flask -a appname.py initdb produces the following: (the same command without heroku run also initializes the db on my machine:
▸ Couldn't find that app.
Which is weird since running heroku ls allows me to see appname.py on the current directory.
If you encouter this error:
Couldn't find that app.
It is because you passed an invalid app name as your -a, --app option for heroku run. Run heroku apps to find what are valid names and try again.

Resources