Warn if app-backend can't start-up because missing dir

This commit is contained in:
Oliver Sand
2020-11-25 16:52:29 +01:00
parent b614e81184
commit ff1301d28f
2 changed files with 16 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-app-backend': patch
---
Warn if the app-backend can't start-up because the static directory that should be served is unavailable.
+11 -1
View File
@@ -21,6 +21,7 @@ import { Logger } from 'winston';
import { notFoundHandler, resolvePackagePath } from '@backstage/backend-common';
import { Config } from '@backstage/config';
import { injectConfig, readConfigs } from '../lib/config';
import fs from 'fs-extra';
export interface RouterOptions {
config: Config;
@@ -35,9 +36,18 @@ export async function createRouter(
const { config, logger, appPackageName, staticFallbackHandler } = options;
const appDistDir = resolvePackagePath(appPackageName, 'dist');
logger.info(`Serving static app content from ${appDistDir}`);
const staticDir = resolvePath(appDistDir, 'static');
if (!(await fs.pathExists(staticDir))) {
logger.warn(
`Can't serve static app content from ${staticDir}, directory doesn't exist`,
);
return Router();
}
logger.info(`Serving static app content from ${appDistDir}`);
const appConfigs = await readConfigs({
config,
appDistDir,