Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #39 from solocommand/windows-development
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 authored Mar 10, 2021
2 parents 5a9a3cc + 881dfbb commit ece6e0d
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .graphqlconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"extensions": {
"endpoints": {
"dev": {
"url": "http://0.0.0.0:10002",
"url": "http://localhost:10002",
"headers": {
"x-tenant-key": "${env:TENANT_KEY}"
}
Expand Down
5 changes: 4 additions & 1 deletion packages/export-framework/start-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const CoreConfig = require('./config/core');
const CustomConfig = require('./config/custom');

if (!process.env.LIVERELOAD_PORT) process.env.LIVERELOAD_PORT = 5010;
if (!process.env.EXPOSED_HOST) process.env.EXPOSED_HOST = 'localhost';

const { env } = process;
process.on('unhandledRejection', (e) => { throw e; });

Expand All @@ -19,6 +21,7 @@ module.exports = async ({
coreConfig: incomingCoreConfig,
port = env.PORT || 6008,
exposedPort = env.EXPOSED_PORT || env.PORT || 6008,
exposedHost = env.EXPOSED_HOST,
graphqlUri = env.GRAPHQL_URI,
tenantKey = env.TENANT_KEY,
onAsyncBlockError,
Expand Down Expand Up @@ -103,7 +106,7 @@ module.exports = async ({
name: sitePackage.name,
tenantKey,
graphqlUri,
location: `http://0.0.0.0:${exposedPort}`,
location: `http://${exposedHost}:${exposedPort}`,
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/marko-newsletters/components/live-reload.marko
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isDev } from "@parameter1/base-cms-utils";

$ const { LIVERELOAD_PORT } = process.env;
$ const { LIVERELOAD_PORT, EXPOSED_HOST } = process.env;

<if(isDev && LIVERELOAD_PORT)>
<script src=`http://0.0.0.0:${LIVERELOAD_PORT}/livereload.js` async></script>
<script src=`http://${EXPOSED_HOST}:${LIVERELOAD_PORT}/livereload.js` async></script>
</if>
9 changes: 5 additions & 4 deletions packages/marko-newsletters/start-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const { isFunction: isFn } = require('@parameter1/base-cms-utils');
const express = require('./express');
const loadTemplates = require('./utils/load-templates');

if (!process.env.LIVERELOAD_PORT) {
process.env.LIVERELOAD_PORT = 5010;
}
if (!process.env.LIVERELOAD_PORT) process.env.LIVERELOAD_PORT = 5010;
if (!process.env.EXPOSED_HOST) process.env.EXPOSED_HOST = 'localhost';

const { env } = process;

process.on('unhandledRejection', (e) => { throw e; });
Expand All @@ -24,6 +24,7 @@ module.exports = async ({
coreConfig,
port = env.PORT || 5008,
exposedPort = env.EXPOSED_PORT || env.PORT || 5008,
exposedHost = env.EXPOSED_HOST,
graphqlUri = env.GRAPHQL_URI,
tenantKey = env.TENANT_KEY,
publicPath, // path to load public assets. will resolve from rootDir.
Expand Down Expand Up @@ -111,7 +112,7 @@ module.exports = async ({
name: sitePackage.name,
tenantKey,
graphqlUri,
location: `http://0.0.0.0:${exposedPort}`,
location: `http://${exposedHost}:${exposedPort}`,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isDev from '../../../utils/is-dev';

$ const { LIVERELOAD_PORT } = process.env;
$ const { LIVERELOAD_PORT, EXPOSED_HOST } = process.env;

<if(isDev && LIVERELOAD_PORT)>
<script src=`http://0.0.0.0:${LIVERELOAD_PORT}/livereload.js` async></script>
<script src=`http://${EXPOSED_HOST}:${LIVERELOAD_PORT}/livereload.js` async></script>
</if>
9 changes: 5 additions & 4 deletions packages/marko-web/start-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const errorHandlers = require('./express/error-handlers');
const express = require('./express');
const loadMore = require('./express/load-more');

if (!process.env.LIVERELOAD_PORT) {
process.env.LIVERELOAD_PORT = 4010;
}
if (!process.env.LIVERELOAD_PORT) process.env.LIVERELOAD_PORT = 4010;
if (!process.env.EXPOSED_HOST) process.env.EXPOSED_HOST = 'localhost';

const { env } = process;

process.on('unhandledRejection', (e) => { throw e; });
Expand All @@ -23,6 +23,7 @@ module.exports = async ({
helmetConfig,
port = env.PORT || 4008,
exposedPort = env.EXPOSED_PORT || env.PORT || 4008,
exposedHost = env.EXPOSED_HOST,
routes,
graphqlUri = env.GRAPHQL_URI,
tenantKey = env.TENANT_KEY,
Expand Down Expand Up @@ -134,7 +135,7 @@ module.exports = async ({
name: sitePackage.name,
siteId,
graphqlUri,
location: `http://0.0.0.0:${exposedPort}`,
location: `http://${exposedHost}:${exposedPort}`,
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/micro/src/service/json-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = async ({
signals = ['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGQUIT'],
healthCheckPath = '/_health',
port = 80,
exposedHost = 'localhost',
exposedPort = 80,
onError,
onStart,
Expand Down Expand Up @@ -127,5 +128,5 @@ module.exports = async ({
},
});

server.listen(port, () => log(`Ready on http://0.0.0.0:${exposedPort}`));
server.listen(port, () => log(`Ready on http://${exposedHost}:${exposedPort}`));
};
1 change: 1 addition & 0 deletions services/graphql-server/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = cleanEnv(process.env, {
REDIS_CACHE_DSN: nonemptystr({ desc: 'The Redis DSN where cache values should be saved.' }),
GRAPHQL_ENDPOINT: nonemptystr({ desc: 'The GraphQL endpoint', default: '/' }),
PORT: port({ desc: 'The internal port to run on.', default: 80 }),
EXPOSED_HOST: str({ desc: 'The external host to run on.', default: 'localhost' }),
EXPOSED_PORT: port({ desc: 'The external port to run on.', default: 80 }),
NEW_RELIC_ENABLED: bool({ desc: 'Whether New Relic is enabled.', default: true, devDefault: false }),
NEW_RELIC_LICENSE_KEY: str({ desc: 'The license key for New Relic.', default: '' }),
Expand Down
3 changes: 2 additions & 1 deletion services/graphql-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { createTerminus } = require('@godaddy/terminus');
const newrelic = require('./newrelic');
const {
PORT,
EXPOSED_HOST,
EXPOSED_PORT,
TERMINUS_TIMEOUT: timeout,
TERMINUS_SHUTDOWN_DELAY: beforeShutdownTimeout,
Expand Down Expand Up @@ -37,7 +38,7 @@ const run = async () => {
onShutdown: () => log('> Cleanup finished. Shutting down.'),
});

server.listen(PORT, () => log(`> Ready on http://0.0.0.0:${EXPOSED_PORT}`));
server.listen(PORT, () => log(`> Ready on http://${EXPOSED_HOST}:${EXPOSED_PORT}`));
};

// Simulate future NodeJS behavior by throwing unhandled Promise rejections.
Expand Down
4 changes: 4 additions & 0 deletions services/hooks/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ const {
custom,
cleanEnv,
bool,
port,
str,
} = envalid;
const { nonemptystr } = custom;

module.exports = cleanEnv(process.env, {
ENABLE_BASEDB_LOGGING: bool({ desc: 'Whether the BaseDB instance should log to the console.', default: false }),
NEW_RELIC_ENABLED: bool({ desc: 'Whether New Relic is enabled.', default: true, devDefault: false }),
NEW_RELIC_LICENSE_KEY: nonemptystr({ desc: 'The license key for New Relic.', devDefault: '(unset)' }),
EXPOSED_HOST: str({ desc: 'The external host to run on.', default: 'localhost' }),
EXPOSED_PORT: port({ desc: 'The external port to run on.', default: 10012 }),
CAPRICA_DSN: nonemptystr({ desc: 'The Base Caprica MongoDB connection URL.' }),
LEONIS_DSN: nonemptystr({ desc: 'The Base Leonis MongoDB connection URL.' }),
TAURON_DSN: nonemptystr({ desc: 'The Base Tauron MongoDB connection URL.' }),
Expand Down
3 changes: 2 additions & 1 deletion services/hooks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const app = require('./app');
const pkg = require('../package.json');
const services = require('./services');
const { log } = require('./output');
const { EXPOSED_HOST, EXPOSED_PORT } = require('./env');

const server = http.createServer(app);

Expand All @@ -22,7 +23,7 @@ const run = async () => {
onShutdown: () => log('> Cleanup finished. Shutting down.'),
});

server.listen(80, () => log('> Ready on http://0.0.0.0:10012'));
server.listen(80, () => log(`> Ready on http://${EXPOSED_HOST}:${EXPOSED_PORT}`));
};

// Simulate future NodeJS behavior by throwing unhandled Promise rejections.
Expand Down
4 changes: 4 additions & 0 deletions services/oembed/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ const {
cleanEnv,
bool,
num,
port,
str,
} = envalid;
const { nonemptystr } = custom;

module.exports = cleanEnv(process.env, {
EMBEDLY_API_KEY: nonemptystr({ desc: 'The Embed.ly API key..' }),
NEW_RELIC_ENABLED: bool({ desc: 'Whether New Relic is enabled.', default: true, devDefault: false }),
NEW_RELIC_LICENSE_KEY: nonemptystr({ desc: 'The license key for New Relic.', devDefault: '(unset)' }),
EXPOSED_HOST: str({ desc: 'The external host to run on.', default: 'localhost' }),
EXPOSED_PORT: port({ desc: 'The external port to run on.', default: 10013 }),
TERMINUS_TIMEOUT: num({ desc: 'Number of milliseconds before forceful exiting', default: 1000 }),
TERMINUS_SHUTDOWN_DELAY: num({ desc: 'Number of milliseconds before the HTTP server starts its shutdown', default: 10000 }),
});
3 changes: 2 additions & 1 deletion services/oembed/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
} = require('./env');
const app = require('./app');
const pkg = require('../package.json');
const { EXPOSED_HOST, EXPOSED_PORT } = require('./env');

const { log } = console;

Expand All @@ -29,7 +30,7 @@ const run = async () => {
onShutdown: () => log('> Cleanup finished. Shutting down.'),
});

server.listen(80, () => log('> Ready on http://0.0.0.0:10013'));
server.listen(80, () => log(`> Ready on http://${EXPOSED_HOST}:${EXPOSED_PORT}`));
};

// Simulate future NodeJS behavior by throwing unhandled Promise rejections.
Expand Down
1 change: 1 addition & 0 deletions services/omail-link-processor/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {

module.exports = cleanEnv(process.env, {
GRAPHQL_URI: str({ desc: 'The BaseCMS GraphQL URL.' }),
EXPOSED_HOST: str({ desc: 'The external host to run on.', default: 'localhost' }),
EXPOSED_PORT: port({ desc: 'The external port that express is exposed on.', default: 80 }),
NEW_RELIC_ENABLED: bool({ desc: 'Whether New Relic is enabled.', default: true, devDefault: false }),
NEW_RELIC_LICENSE_KEY: str({ desc: 'The license key for New Relic.', devDefault: '(unset)' }),
Expand Down
3 changes: 2 additions & 1 deletion services/omail-link-processor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const pkg = require('../package.json');
const newrelic = require('./newrelic');
const {
PORT,
EXPOSED_HOST,
EXPOSED_PORT,
TERMINUS_SHUTDOWN_DELAY,
TERMINUS_TIMEOUT,
Expand Down Expand Up @@ -41,7 +42,7 @@ const run = async () => {
};

run()
.then(() => log(`${pkg.name} v${pkg.version} running on http://0.0.0.0:${EXPOSED_PORT}`))
.then(() => log(`${pkg.name} v${pkg.version} running on http://${EXPOSED_HOST}:${EXPOSED_PORT}`))
.catch(e => setImmediate(() => {
newrelic.noticeError(e);
throw e;
Expand Down
2 changes: 2 additions & 0 deletions services/rss/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const {
bool,
port,
num,
str,
} = envalid;
const { nonemptystr } = validators;

module.exports = cleanEnv(process.env, {
GRAPHQL_URI: nonemptystr({ desc: 'The BaseCMS GraphQL API URL.' }),
PORT: port({ desc: 'The internal port to run on.', default: 80 }),
EXPOSED_HOST: str({ desc: 'The external host to run on.', default: 'localhost' }),
EXPOSED_PORT: port({ desc: 'The external port to run on.', default: 80 }),
NEW_RELIC_ENABLED: bool({ desc: 'Whether New Relic is enabled.', default: true, devDefault: false }),
NEW_RELIC_LICENSE_KEY: nonemptystr({ desc: 'The license key for New Relic.', devDefault: '(unset)' }),
Expand Down
3 changes: 2 additions & 1 deletion services/rss/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const newrelic = require('./newrelic');
const {
GRAPHQL_URI,
PORT,
EXPOSED_HOST,
EXPOSED_PORT,
TERMINUS_TIMEOUT: timeout,
TERMINUS_SHUTDOWN_DELAY: beforeShutdownTimeout,
Expand All @@ -31,7 +32,7 @@ const run = async () => {
onShutdown: () => log('> Cleanup finished. Shutting down.'),
});

server.listen(PORT, () => log(`> Ready on http://0.0.0.0:${EXPOSED_PORT}, using GraphQL API ${GRAPHQL_URI}`));
server.listen(PORT, () => log(`> Ready on http://${EXPOSED_HOST}:${EXPOSED_PORT}, using GraphQL API ${GRAPHQL_URI}`));
};

// Simulate future NodeJS behavior by throwing unhandled Promise rejections.
Expand Down
2 changes: 2 additions & 0 deletions services/sitemaps/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const {
bool,
num,
port,
str,
} = envalid;
const { nonemptystr } = validators;

module.exports = cleanEnv(process.env, {
GRAPHQL_URI: nonemptystr({ desc: 'The BaseCMS GraphQL API URL.' }),
PORT: port({ desc: 'The internal port to run on.', default: 80 }),
EXPOSED_HOST: str({ desc: 'The external host to run on.', default: 'localhost' }),
EXPOSED_PORT: port({ desc: 'The external port to run on.', default: 80 }),
PAGE_SIZE: num({ desc: 'The number of urls per page', default: 5000 }),
NEW_RELIC_ENABLED: bool({ desc: 'Whether New Relic is enabled.', default: true, devDefault: false }),
Expand Down
3 changes: 2 additions & 1 deletion services/sitemaps/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const newrelic = require('./newrelic');
const {
GRAPHQL_URI,
PORT,
EXPOSED_HOST,
EXPOSED_PORT,
TERMINUS_TIMEOUT: timeout,
TERMINUS_SHUTDOWN_DELAY: beforeShutdownTimeout,
Expand All @@ -31,7 +32,7 @@ const run = async () => {
onShutdown: () => log('> Cleanup finished. Shutting down.'),
});

server.listen(PORT, () => log(`> Ready on http://0.0.0.0:${EXPOSED_PORT}, using GraphQL API ${GRAPHQL_URI}`));
server.listen(PORT, () => log(`> Ready on http://${EXPOSED_HOST}:${EXPOSED_PORT}, using GraphQL API ${GRAPHQL_URI}`));
};

// Simulate future NodeJS behavior by throwing unhandled Promise rejections.
Expand Down

0 comments on commit ece6e0d

Please sign in to comment.