I followed the official tutorial on how to deploy an Aqueduct application on Heroku (i.e. https://aqueduct.io/docs/deploy/deploy_heroku/). I was able to successfully connect to a PostgreSQL database and push the initial migration using a release dyno, however when I try to run the application using a web dyno, I get the following error:
2020-09-12T08:37:48.024346+00:00 app[web.1]: -- Preparing...
2020-09-12T08:38:13.885510+00:00 app[web.1]: -- Starting application 'easyprintbot/easyprintbot'
2020-09-12T08:38:13.891105+00:00 app[web.1]: Channel: EasyprintbotChannel
2020-09-12T08:38:13.891309+00:00 app[web.1]: Config: /app/heroku.yaml
2020-09-12T08:38:13.896358+00:00 app[web.1]: Port: 50277
2020-09-12T08:38:50.094519+00:00 app[web.1]: [INFO] aqueduct: Server aqueduct/1 started.
2020-09-12T08:40:43.299225+00:00 heroku[web.1]: Error R10 (Boot timeout) ->
Web process failed to bind to $PORT within 180 seconds of launch
2020-09-12T08:40:43.321337+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-09-12T08:40:43.660088+00:00 heroku[web.1]: Process exited with status 137
2020-09-12T08:40:43.754862+00:00 heroku[web.1]: State changed from starting
to crashed
I even tried to extend my boot time to 180 seconds but still got the same error and then adjusted my bin/main.dart file to this:
import 'dart:io' show Platform;
import 'package:easyprintbot/easyprintbot.dart';
Future main() async {
//Getting port from the Process env file
var portEnv = Platform.environment['PORT'];
//Setting port to 8888 if fetch failed else setting it to the fetched value
var port = portEnv == null ? 8888 : int.parse(portEnv);
print("Port: {$port}");
final app = Application<EasyprintbotChannel>()
..options.configurationFilePath = "heroku.yaml"
..options.port = port; //setting port to bind to
await app.startOnCurrentIsolate();
print("Application started on port: ${app.options.port}.");
print("Use Ctrl-C (SIGINT) to stop running the application.");
}
I still get the same error after redeployment.
My Procfile looks like this:
release: /app/dart-sdk/bin/pub global run aqueduct:aqueduct db upgrade --connect $DATABASE_URL
web: /app/dart-sdk/bin/pub global run aqueduct:aqueduct serve --port $PORT --config-path heroku.yaml
and my heroku.yaml looks like this:
database: $DATABASE_URL
What am I doing wrong?