run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
final args = argResults!;
final role = requireRole(args);
final manager = _serviceManager(verbose: args['verbose'] as bool);
await runService(() async {
final svc.ServiceDescriptor descriptor;
if (_hasConfigOverride(args)) {
descriptor = serviceDescriptor(role, args);
} else {
// Reuse mode: rebuild the descriptor for *this* executable — so the
// binary refreshes — from the config already installed.
final svc.ServiceInfo info;
try {
info = await manager.describe(servicePackage, role);
} on svc.ServiceNotFoundException {
throw CliError(
'"$role" is not installed; pass install options to install it '
'(e.g. `omnyserver service install $role …`).',
);
}
descriptor = svc.ServiceDescriptor.forCurrentExecutable(
packageName: servicePackage,
serviceName: role,
arguments: info.entry.arguments,
environment: info.entry.environment,
scope: info.entry.scope,
restart: svc.RestartPolicy.always,
);
}
if (args['dry-run'] as bool) {
stdout.writeln(manager.renderDefinition(descriptor));
return;
}
await manager.reinstall(descriptor, startNow: true);
stdout.writeln(
'Reinstalled service "$role" (${descriptor.scope.name} scope).',
);
});
}