You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a global variable isRunning and a loop myLoop in globals.dart which starts when /test route is hit. When there are no requests to /test route for few minutes (Don't know the specific duration) and /test route gets a hit then isRunning gets ignored and loop starts twice.
To start the server server.dart:
import'dart:io';
import'dart:isolate';
import'package:shelf/shelf.dart';
import'package:shelf/shelf_io.dart';
import'router.dart';
voidmain() {
int numberOfCores =Platform.numberOfProcessors;
final handler =constPipeline()
.addMiddleware(
logRequests(),
)
.addHandler(router);
for (int i =1; i < numberOfCores; i++) {
Isolate.spawn(startServer, handler);
}
startServer(handler);
}
startServer(Handler handler) async {
HttpServer myserver =awaitserve(
handler,
'0.0.0.0',
8000,
shared:true,
);
print('Serving at http://${myserver.address.host}:${myserver.port}');
}
I have a global variable
isRunning
and a loopmyLoop
inglobals.dart
which starts when/test
route is hit. When there are no requests to/test
route for few minutes (Don't know the specific duration) and/test
route gets a hit thenisRunning
gets ignored and loop starts twice.To start the server
server.dart
:Handle routes
router.dart
:Testing controller
test_controller.dart
:Global functions and variables
globals.dart
:Output:
The text was updated successfully, but these errors were encountered: