1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/src/server-dev.ts
Salvatore Novelli 7ddbff2669
feat: add "application_name" as an optional DB option #1170 (#1478)
* implemented changes to resolve issue 1170

* added applicationName to the list of db options in the documentation'

Co-authored-by: Daniele Casal <daniele.casal@lloydsbanking.com>
Co-authored-by: Sukhvinder Panesar <79143027+esspee-lbg@users.noreply.github.com>
2022-04-07 20:55:56 +02:00

62 lines
2.2 KiB
TypeScript

import { start } from './lib/server-impl';
import { createConfig } from './lib/create-config';
import { LogLevel } from './lib/logger';
import { ApiTokenType } from './lib/types/models/api-token';
import { experimentalSegmentsConfig } from './lib/experimental';
process.nextTick(async () => {
try {
await start(
createConfig({
db: {
user: 'unleash_user',
password: 'passord',
host: 'localhost',
port: 5432,
database: process.env.UNLEASH_DATABASE_NAME || 'unleash',
schema: process.env.UNLEASH_DATABASE_SCHEMA,
ssl: false,
applicationName: 'unleash',
},
server: {
enableRequestLogger: true,
baseUriPath: '',
// keepAliveTimeout: 1,
gracefulShutdownEnable: true,
// cdnPrefix: 'https://cdn.getunleash.io/unleash/v4.4.1',
},
logLevel: LogLevel.debug,
enableOAS: true,
// secureHeaders: true,
versionCheck: {
enable: false,
},
experimental: {
metricsV2: { enabled: true },
segments: experimentalSegmentsConfig(),
},
authentication: {
initApiTokens: [
{
environment: '*',
project: '*',
secret: '*:*.964a287e1b728cb5f4f3e0120df92cb5',
type: ApiTokenType.ADMIN,
username: 'some-user',
},
],
},
}),
);
} catch (error) {
if (error.code === 'EADDRINUSE') {
// eslint-disable-next-line no-console
console.warn('Port in use. You might want to reload once more.');
} else {
// eslint-disable-next-line no-console
console.error(error);
process.exit();
}
}
}, 0);