authService function

Future<void> authService(
  1. List args
)

auth-service must run on an isolate.

Implementation

Future<void> authService(List<dynamic> args) async {
  if (Platform.environment['GIT_LFS_SERVER_TRACE'] != null) {
    Logger.root.level = Level.ALL;
  } else {
    Logger.root.level = Level.INFO;
  }
  if (args.length < 3) {
    _log.severe('Missing arguments!');
    return;
  }

  final sendPortData = args[0] as SendPort;
  final sendPortCmd = args[1] as SendPort;
  final url = args[2] as String;

  final udsa = InternetAddress(lfs.filelock, type: InternetAddressType.unix);
  final service = _AuthenticationService(url, sendPortData);
  final server = Server([service]);
  server.serve(address: udsa);
  _log.info('$tag has started.');

  sendPortCmd.send(service.receivePortCmd.sendPort);

  // git-lfs-server only sends null to shutdown git-lfs-auth-service
  await service.receivePortCmd.first;

  _log.fine('$tag is shutting down.');
  await server.shutdown();
  _log.info('$tag has shutdown.');
  Isolate.exit();
}