2019-04-18 02:11:23 +00:00
|
|
|
// @flow
|
2020-07-10 05:33:07 +00:00
|
|
|
require("./init");
|
2017-11-10 23:24:29 +00:00
|
|
|
|
2019-08-24 05:43:41 +00:00
|
|
|
if (
|
|
|
|
!process.env.SECRET_KEY ||
|
2020-07-10 05:33:07 +00:00
|
|
|
process.env.SECRET_KEY === "generate_a_new_key"
|
2019-08-24 05:43:41 +00:00
|
|
|
) {
|
|
|
|
console.error(
|
2020-07-10 05:33:07 +00:00
|
|
|
"The SECRET_KEY env variable must be set with the output of `openssl rand -hex 32`"
|
2017-11-10 23:24:29 +00:00
|
|
|
);
|
2019-08-24 05:43:41 +00:00
|
|
|
// $FlowFixMe
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2019-08-24 17:19:21 +00:00
|
|
|
if (process.env.AWS_ACCESS_KEY_ID) {
|
|
|
|
[
|
2020-07-10 05:33:07 +00:00
|
|
|
"AWS_REGION",
|
|
|
|
"AWS_SECRET_ACCESS_KEY",
|
|
|
|
"AWS_S3_UPLOAD_BUCKET_URL",
|
|
|
|
"AWS_S3_UPLOAD_BUCKET_NAME",
|
|
|
|
"AWS_S3_UPLOAD_MAX_SIZE",
|
2019-08-24 17:19:21 +00:00
|
|
|
].forEach(key => {
|
|
|
|
if (!process.env[key]) {
|
|
|
|
console.error(`The ${key} env variable must be set when using AWS`);
|
|
|
|
// $FlowFixMe
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.SLACK_KEY) {
|
2020-03-16 03:53:15 +00:00
|
|
|
if (!process.env.SLACK_SECRET) {
|
|
|
|
console.error(
|
|
|
|
`The SLACK_SECRET env variable must be set when using Slack Sign In`
|
|
|
|
);
|
|
|
|
// $FlowFixMe
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2017-11-10 23:24:29 +00:00
|
|
|
}
|
|
|
|
|
2019-08-24 05:43:41 +00:00
|
|
|
if (!process.env.URL) {
|
2017-11-10 23:24:29 +00:00
|
|
|
console.error(
|
2020-07-10 05:33:07 +00:00
|
|
|
"The URL env variable must be set to the externally accessible URL, e.g (https://www.getoutline.com)"
|
2017-11-10 23:24:29 +00:00
|
|
|
);
|
2019-04-18 02:11:23 +00:00
|
|
|
// $FlowFixMe
|
2017-11-10 23:24:29 +00:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2019-08-24 05:43:41 +00:00
|
|
|
if (!process.env.DATABASE_URL) {
|
|
|
|
console.error(
|
2020-07-10 05:33:07 +00:00
|
|
|
"The DATABASE_URL env variable must be set to the location of your postgres server, including authentication and port"
|
2019-08-24 05:43:41 +00:00
|
|
|
);
|
|
|
|
// $FlowFixMe
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!process.env.REDIS_URL) {
|
|
|
|
console.error(
|
2020-07-10 05:33:07 +00:00
|
|
|
"The REDIS_URL env variable must be set to the location of your redis server, including authentication and port"
|
2019-08-24 05:43:41 +00:00
|
|
|
);
|
|
|
|
// $FlowFixMe
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2019-08-24 17:19:21 +00:00
|
|
|
if (!process.env.WEBSOCKETS_ENABLED) {
|
|
|
|
console.log(
|
2020-07-10 05:33:07 +00:00
|
|
|
"WARNING: Websockets are disabled. Set WEBSOCKETS_ENABLED env variable to true to enable"
|
2019-08-24 17:19:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-10 05:33:07 +00:00
|
|
|
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") {
|
2019-08-24 05:43:41 +00:00
|
|
|
console.log(
|
2020-07-10 05:33:07 +00:00
|
|
|
"\n\x1b[33m%s\x1b[0m",
|
2019-08-24 05:43:41 +00:00
|
|
|
'Running Outline in development mode with hot reloading. To run Outline in production mode set the NODE_ENV env variable to "production"'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-10 05:33:07 +00:00
|
|
|
require("./server");
|