Reputation: 511896
My main.dart file for my Aqueduct server is
import 'package:dart_server/dart_server.dart';
Future main() async {
final app = Application<DartServerChannel>()
..options.configurationFilePath = "config.yaml"
..options.port = 3000; // changed from 8888
final count = Platform.numberOfProcessors ~/ 2;
await app.start(numberOfInstances: 1); // changed from count > 0 ? count : 1
print("Application started on port: ${app.options.port}.");
print("Use Ctrl-C (SIGINT) to stop running the application.");
}
I changed the port number and the number of instances, but when I start the server with
aqueduct serve
I still get port 8888 and two instances:
-- Aqueduct CLI Version: 3.1.0+1
-- Aqueduct project version: 3.1.0+1
-- Preparing...
-- Starting application 'dart_server/dart_server'
Channel: DartServerChannel
Config: /Users/jonathan/Documents/Programming/Tutorials/Flutter/backend/backend_app/dart_server/config.yaml
Port: 8888
[INFO] aqueduct: Server aqueduct/1 started.
[INFO] aqueduct: Server aqueduct/2 started.
Only if I explicitly start the server like this
aqueduct serve --port 3000 --isolates 1
do I get port 3000 and one instance:
-- Aqueduct CLI Version: 3.1.0+1
-- Aqueduct project version: 3.1.0+1
-- Preparing...
-- Starting application 'dart_server/dart_server'
Channel: DartServerChannel
Config: /Users/jonathan/Documents/Programming/Tutorials/Flutter/backend/backend_app/dart_server/config.yaml
Port: 3000
[INFO] aqueduct: Server aqueduct/1 started.
Why didn't changing main.dart affect it? (I saved the file after making changes.) Is there somewhere else that I need to make the update?
Upvotes: 1
Views: 438
Reputation: 101
I don't find it in any documentation but it seems that when you run "aqueduct serve" command, the bin/main.dart file isn't executed. The aqueduct serve command uses its own configuration on command line. You need to specify the port using the -port option.
If you want to use your main.dart file you can also execute the server directly using
dart bin/main.dart
in your project folder.
Upvotes: 3