Heroku | interactive
The ps-exec.sh
utility is a wrapper for the heroku ps:exec
command. It starts an SSH server daemon alongside the processes that are running in the dyno.
This mode is useful when there's a necessity to check or change the state of an application in a particular dyno. However it's more intrusive since it allows to interact it directly with the state of the app.
Caveats
- Sometime the command fails silently to get executed
- Requires restarting dynos if this feature is not eanabled for the app
- Sometimes requires restarting the dyno informing that the dyno is not available
Connection Configuration
Name | Type | Description |
---|---|---|
HEROKU_API_KEY | env-var | The API KEY to interact with heroku platform API |
Connection Command
/app/bin/ps-exec.sh
How to Use
This modes requires the feature runtime-heroku-exec, the ps-exec.sh
script will restart the app without any prompt if the feature is not enabled. Reference
Check the help usage for this connection
hoop exec heroku:psexec -- --help
Starting an interactive session
# bash interactive session
hoop connect heroku:psexec -- --interactive --app [APP-NAME]
The heroku ps:exec
command doesn't allow starting interactive sessions with other processes, only with bash
.
To run one-off processes. The --pipe
option pipes the command to the given executable in the app.
hoop exec heroku:psexec -- --app [APP-NAME] --pipe 'python' <<EOF
import os
print(os.environ)
EOF
# run in a specific dyno
hoop exec heroku:psexec -i 'pp ENV' -- --app [APP-NAME] --dyno web.2 --pipe 'rails runner -'
hoop exec heroku:psexec -i 'ls -l' -- --app [APP-NAME] --pipe 'bash'
echo 'import os; print(os.environ)' | hoop exec heroku:psexec -- --app [APP-NAME] --pipe 'python'
Check the status of the SSH in the app
hoop exec heroku:psexec -- --app [APP-NAME] --status