-
Notifications
You must be signed in to change notification settings - Fork 3
Heroku
There are a few minimal requirements that your addon must meet in order to deploy it to Heroku. You don't need any additional dependencies or complex config files. After applying any of the changes below, your project will still work locally too!
Requirements:
- Addon must use the port from the
PORT
environment variable, because heroku allocates a random port per deployment. - Addon must listen on all interfaces. That is
0.0.0.0
instead of the usual127.0.0.1
.
Make sure that the port
and ip
properties of ServerOptions
are properly configured like this:
let options = ServerOptions {
// cache all responses for 7 days
cache_max_age: 24 * 3600 * 7,
// use port from environment variable or 1337 if not set
port: env::var("PORT").ok().and_then(|port| port.parse().ok()).unwrap_or(1337),
// listen on all interfaces
ip: Ipv4Addr::new(0, 0, 0, 0).into(),
};
Add a new file named Procfile
to the root of your project and add the following line to it: web ./target/release/example-addon
(replace example-addon
with your project/package name).
Then create a new heroku app if you haven't done so already and link a Rust buildpack to it with the following command: heroku buildbpacks:set emk/rust
.
Finally, push your changes to heroku and watch the magic happen!