Heroku execute session one-off
This mode is less intrusive and allows executing one-off dynos that runs a standalone process with the state of your application code. It's useful to perform ad-hoc actions using the current state of your application code, like database migrations.
Caveats
- Use of one-off dynos generates additional costs
- Doesn't allow to interact with the state of a running app
Connection Configuration
Name | Type | Description |
---|---|---|
HEROKU_API_KEY | env-var | The API KEY to interact with heroku platform API |
Connection Command
/app/bin/heroku run --exit-code
How to Use
Start an interactive session with the one-off dyno
# bash interactive session
hoop connect heroku:run -- --app [APP-NAME] bash
# python3 or rails console interactive session
hoop connect heroku:run -- --app [APP-NAME] python
hoop connect heroku:run -- --app [APP-NAME] rails console
In the same connection, one-off process can be run as well
hoop exec heroku:run -- --no-tty --app [APP-NAME] python3 <<EOF
import os
print(os.environ)
EOF
hoop exec heroku:run -- python3 <<EOF
import os
print(os.environ)
EOF
hoop exec heroku:run -i 'pp ENV' -- --no-tty --app [APP-NAME] rails runner -
hoop exec heroku:run -i 'import os; print(os.environ)' -- python3
hoop exec heroku:run -i 'uname -a' -- bash