23 lines
683 B
Dart
23 lines
683 B
Dart
import 'dart:developer' as dev;
|
|
import 'dart:io';
|
|
|
|
import 'package:backend/utils/environment.dart';
|
|
import 'package:dart_frog/dart_frog.dart';
|
|
import 'package:shared_models/fart_logger.dart';
|
|
|
|
bool _listening = false;
|
|
|
|
Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
|
|
final isDevelopment = (await dev.Service.getInfo()).serverUri != null;
|
|
// Logic to prevent multiple listeners with hot-reload
|
|
// Changes to this are not hot-reloaded, you must restart the server
|
|
if (!_listening) {
|
|
FartLogger.listen(isDevelopment: isDevelopment);
|
|
_listening = true;
|
|
}
|
|
|
|
checkEnvironment(isDevEnv: isDevelopment);
|
|
|
|
return serve(handler, ip, port);
|
|
}
|