From 9f58a08fcb865a79ef8b4427d0484e7b855af558 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 1 Jun 2019 21:38:21 -0400 Subject: [PATCH] feat: heroku compatibility --- dev/build/Dockerfile | 2 ++ wiki.js => dev/index.js | 22 ++++------------------ package.json | 5 +---- server/core/config.js | 2 +- server/core/db.js | 2 +- 5 files changed, 9 insertions(+), 24 deletions(-) rename wiki.js => dev/index.js (83%) diff --git a/dev/build/Dockerfile b/dev/build/Dockerfile index 3dbf41c4..dc1fef97 100644 --- a/dev/build/Dockerfile +++ b/dev/build/Dockerfile @@ -46,4 +46,6 @@ USER node EXPOSE 3000 +# HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD curl -f http://localhost/healthz + CMD ["node", "server"] diff --git a/wiki.js b/dev/index.js similarity index 83% rename from wiki.js rename to dev/index.js index 94cc2f86..8ef00ea6 100644 --- a/wiki.js +++ b/dev/index.js @@ -15,7 +15,7 @@ const init = { const chokidar = require('chokidar') global.DEV = true - global.WP_CONFIG = require('./dev/webpack/webpack.dev.js') + global.WP_CONFIG = require('./webpack/webpack.dev.js') global.WP = webpack(global.WP_CONFIG) global.WP_DEV = { devMiddleware: require('webpack-dev-middleware')(global.WP, { @@ -25,7 +25,7 @@ const init = { } global.WP_DEV.devMiddleware.waitUntilValid(() => { console.info(chalk.yellow.bold('>>> Starting Wiki.js in DEVELOPER mode...')) - require('./server') + require('../server') process.stdin.setEncoding('utf8') process.stdin.on('data', data => { @@ -84,22 +84,8 @@ const init = { process.removeAllListeners('unhandledRejection') process.removeAllListeners('uncaughtException') - require('./server') + require('../server') } } -require('yargs') // eslint-disable-line no-unused-expressions - .usage('Usage: node $0 [args]') - .command({ - command: 'dev', - desc: 'Start in Developer Mode', - handler: argv => { - init.dev() - } - }) - .recommendCommands() - .demandCommand(1, 'You must provide one of the accepted commands above.') - .help() - .version() - .epilogue('Read the docs at https://docs-beta.requarks.io/dev') - .argv +init.dev() diff --git a/package.json b/package.json index 4935d0c6..71ec7880 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,11 @@ "main": "wiki.js", "scripts": { "start": "node server", - "dev": "node wiki dev", + "dev": "node dev", "build": "webpack --profile --config dev/webpack/webpack.prod.js", "watch": "webpack --config dev/webpack/webpack.dev.js", "test": "eslint --format codeframe --ext .js,.vue . && pug-lint server/views && jest" }, - "bin": { - "wiki": "wiki.js" - }, "repository": { "type": "git", "url": "git+https://github.com/Requarks/wiki.git" diff --git a/server/core/config.js b/server/core/config.js index 6eb50652..c7e57b40 100644 --- a/server/core/config.js +++ b/server/core/config.js @@ -48,7 +48,7 @@ module.exports = { appconfig = _.defaultsDeep(appconfig, appdata.defaults.config) - if (appconfig.port < 1) { + if (appconfig.port < 1 || process.env.HEROKU) { appconfig.port = process.env.PORT || 80 } diff --git a/server/core/db.js b/server/core/db.js index 9b8a8770..2b6fe413 100644 --- a/server/core/db.js +++ b/server/core/db.js @@ -24,7 +24,7 @@ module.exports = { let self = this let dbClient = null - let dbConfig = (!_.isEmpty(process.env.WIKI_DB_CONNSTR)) ? process.env.WIKI_DB_CONNSTR : { + let dbConfig = (!_.isEmpty(process.env.DATABASE_URL)) ? process.env.DATABASE_URL : { host: WIKI.config.db.host, user: WIKI.config.db.user, password: WIKI.config.db.pass,