chore: Add additional env variable checks for self-hosted installations

This commit is contained in:
Tom Moor
2019-08-23 22:43:41 -07:00
parent 8f2d31876d
commit b6dd55fbea

View File

@@ -1,28 +1,56 @@
// @flow
require('./init');
if (process.env.NODE_ENV === 'production') {
console.log(
'\n\x1b[33m%s\x1b[0m',
'Running Outline in production mode. Use `yarn dev` to run in development with live code reloading'
);
} else if (process.env.NODE_ENV === 'development') {
console.log(
'\n\x1b[33m%s\x1b[0m',
'Running Outline in development mode with hot reloading. To run Outline in production mode, use `yarn start`'
);
}
if (
!process.env.SECRET_KEY ||
process.env.SECRET_KEY ===
'F0E5AD933D7F6FD8F4DBB3E038C501C052DC0593C686D21ACB30AE205D2F634B'
process.env.SECRET_KEY === 'generate_a_new_key'
) {
console.error(
'Please set SECRET_KEY env variable with output of `openssl rand -hex 32`'
'The SECRET_KEY env variable must be set with the output of `openssl rand -hex 32`'
);
// $FlowFixMe
process.exit(1);
}
if (process.env.AWS_ACCESS_KEY_ID && !process.env.AWS_REGION) {
console.error(
'The AWS_REGION env variable must be set when using AWS, e.g (us-east-1)'
);
// $FlowFixMe
process.exit(1);
}
if (!process.env.URL) {
console.error(
'The URL env variable must be set to the externally accessible URL, e.g (https://www.getoutline.com)'
);
// $FlowFixMe
process.exit(1);
}
if (!process.env.DATABASE_URL) {
console.error(
'The DATABASE_URL env variable must be set to the location of your postgres server, including authentication and port'
);
// $FlowFixMe
process.exit(1);
}
if (!process.env.REDIS_URL) {
console.error(
'The REDIS_URL env variable must be set to the location of your redis server, including authentication and port'
);
// $FlowFixMe
process.exit(1);
}
if (process.env.NODE_ENV === 'production') {
console.log('\n\x1b[33m%s\x1b[0m', 'Running Outline in production mode.');
} else if (process.env.NODE_ENV === 'development') {
console.log(
'\n\x1b[33m%s\x1b[0m',
'Running Outline in development mode with hot reloading. To run Outline in production mode set the NODE_ENV env variable to "production"'
);
}
require('./server');