1

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?

Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393

1 Answers1

3

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.

Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
  • 4
    Yes, this is correct. `aqueduct serve` generates a script on the fly to start your application and (intentionally) doesn't rely on a particular script file. You'll want to use a start script of your own for debugging and often when packaging your application into a Docker image. Aqueduct serve is more of a convenience for newcomers and quick local runs. – Joe Conway Mar 07 '19 at 16:35