launchDaemon function

Future<int> launchDaemon(
  1. List<String> arguments
)

Start the standalone server,

Implementation

Future<int> launchDaemon(List<String> arguments) async {
  var exitCode = cli.exitNok;
  final flags = cli.extractFlags(arguments);
  if (flags.contains(cli.Flags.help)) {
    _showHelp();
    return cli.exitOk;
  }
  final port = cli.extractOption('-p', '--port', arguments);
  final portNumber = port == null ? defaultPortNumber : int.tryParse(port);
  if (portNumber == null || portNumber < 1024) {
    print('port number invalid {$port,$portNumber}. It should be > 1024');
    return cli.exitNok;
  }
  final collections = cli.getItemsFromFile(arguments);
  if (collections != null && collections.isNotEmpty) {
    _customCollectionItems.addAll(collections);
    //print('${_customCollectionItems.keys}');
  }

  final index = cli.extractOption('-i', '--index', arguments);
  _customIndexHtml = index == null ? null : await File(index).readAsString();

  exitCode = await _startServer(portNumber);
  print('Server Stopped !');

  return exitCode;
}