Skip to content

Commit

Permalink
Make core fail if legacy fails to start.
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin committed Jul 31, 2018
1 parent bd4fadc commit 4f32a9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
5 changes: 0 additions & 5 deletions src/core/cli/apply_config_overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ function* getUnknownArgsOverrides(
) {
// Merge unknown CLI args into config.
for (const unknownArgKey of args.getUnknownOptions(argv, installationFeatures)) {
// Include only arguments that looks like config keys (with `.` as a separator).
if (!unknownArgKey.includes('.')) {
continue;
}

try {
yield [unknownArgKey, JSON.parse(argv[unknownArgKey])];
} catch (e) {
Expand Down
33 changes: 17 additions & 16 deletions src/core/server/legacy_compat/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ interface LegacyServiceOptions {
export class LegacyService implements CoreService {
private readonly log: Logger;
private kbnServer?: LegacyKbnServer;
private kbnServerSubscription?: Subscription;
private rawConfigSubscription?: Subscription;
private readonly connection$: BehaviorSubject<ServerOptions | null> = new BehaviorSubject(null);

constructor(
Expand All @@ -76,35 +76,36 @@ export class LegacyService implements CoreService {
public async start() {
this.log.debug('Starting legacy service');

this.kbnServerSubscription = k$(this.configService.getConfig$())(
map(async rawConfig => {
this.rawConfigSubscription = this.configService.getConfig$().subscribe({
next: rawConfig => {
if (this.kbnServer !== undefined) {
this.kbnServer.applyLoggingConfiguration(rawConfig.getRaw());
return this.kbnServer;
}
},
error: err => this.log.error(err),
});

const kbnServerPromise = await k$(this.configService.getConfig$())(
map(rawConfig => {
if (this.options.isDevClusterMaster) {
return this.createClusterManager(rawConfig);
}

return this.createKbnServer(rawConfig);
})
).subscribe({
next: async kbnServerPromise => {
this.kbnServer = await kbnServerPromise;
}),
first(),
toPromise()
);

await this.kbnServer.listen();
},
error: err => this.log.error(err),
});
this.kbnServer = await kbnServerPromise;
}

public async stop() {
this.log.debug('Stopping legacy service');

if (this.kbnServerSubscription !== undefined) {
this.kbnServerSubscription.unsubscribe();
this.kbnServerSubscription = undefined;
if (this.rawConfigSubscription !== undefined) {
this.rawConfigSubscription.unsubscribe();
this.rawConfigSubscription = undefined;
}

if (this.kbnServer !== undefined) {
Expand Down Expand Up @@ -202,7 +203,7 @@ export class LegacyService implements CoreService {
require(REPL_PATH).startRepl(this.kbnServer);
}

await kbnServer.ready();
await kbnServer.listen();

return kbnServer;
}
Expand Down

0 comments on commit 4f32a9c

Please sign in to comment.