Created
February 23, 2019 02:49
-
-
Save iambudi/b2d84ad5db470f5c56631005e18560c0 to your computer and use it in GitHub Desktop.
Jaguar Dart with Hot Reload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:jaguar/jaguar.dart'; | |
import 'package:jaguar_hotreload/jaguar_hotreload.dart'; | |
import 'package:jaguar_reflect/jaguar_reflect.dart'; | |
import 'dart:io'; | |
import 'dart:isolate'; | |
main() async { | |
final reloader = new HotReloader( | |
debounceInterval: const Duration(seconds: 2) | |
); | |
reloader.addPath('.'); | |
await reloader.addPackageDependencies(); | |
await reloader.go(); | |
for (int i = 0; i < Platform.numberOfProcessors - 1; i++) | |
Isolate.spawn(start, i + 1); | |
start(0); | |
} | |
// run with dart --enable-vm-service server.dart | |
start(int i) async { | |
const port = 3000; | |
print("Instance #$i listening on port $port"); | |
Jaguar server = Jaguar(port: port, multiThread: true); | |
server.get('/', (Context ctx) async { | |
return Response("{'text': 'hello world'}", statusCode: 200); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment