I've tried googling and stackoverflowing this and all I get is links back to the API reference or examples of scaling dynos, which is not what I want.
heroku run:detached
is great as it just spins up a dyno with your app, runs whatever you want, then spins down the dyno.
How do I achieve the exact same things but using the Heroku Platform API?
I've seen people mention you have to use the Dyno
endpoint on the API, but how? Can someone offer an exact example of how I would run the following from the API?
$ heroku run:detached --size 2x rake my_task.rb
Automatic dyno restartscreate a new release by deploying new code. change your config vars. change your add-ons. run heroku restart.
When the Heroku platform receives the application source, it initiates a build of the source application. Under the hood, a git hub webhook is triggered after pushing new Source Code to the master branch. For build and deployment Heroku uses so called buildpacks.
A Procfile is not technically required to deploy simple apps written in most Heroku-supported languages—the platform automatically detects the language and creates a default web process type to boot the application server.
Running Commands on the Heroku Web Interface To use the web console, navigate to your application in Heroku. The same application that you would pass into --app earlier. In the top-right of the interface, there is a “More” button, pressing it displays a “Run Console” option. Select it to add your command.
You can use the platform API to to this, and create a dyno. See https://devcenter.heroku.com/articles/platform-api-reference#dyno-create
By sending a POST
request to /apps/your_app_name/dynos
with the following parameters:
command
, the command you wich to run.attach
, set it to false.This will create a one-off dyno and detach it.
This is what the toolbelt does when you run the run:detached
command. You can see how it works here: https://github.com/heroku/heroku/blob/01cd753570cb62b917843112fb29d1cdd43ba335/lib/heroku/command/run.rb#L65
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With