我的渡槽服务器的main.dart文件是
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.");
}
我更改了端口号和实例数,但是当我使用
启动服务器时aqueduct serve
我仍然获得端口8888和两个实例:
-- 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.
仅当我像这样显式启动服务器时
aqueduct serve --port 3000 --isolates 1
我是否获得端口3000和一个实例:
-- 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.
为什么更改main.dart不会对其产生影响? (我在进行更改后保存了文件。)是否还有其他地方需要进行更新?
答案 0 :(得分:1)
我在任何文档中都没有找到它,但是当您运行“ aqueduct serve”命令时,似乎没有执行bin / main.dart文件。 aqueduct serve命令在命令行上使用其自己的配置。您需要使用-port选项指定端口。
如果要使用main.dart文件,也可以使用
直接执行服务器。dart bin/main.dart
在您的项目文件夹中。