fix: listening and web config
This commit is contained in:
parent
e7353b8a9e
commit
96f23f07a1
|
@ -74,11 +74,17 @@ export const createHttpServer = async (flecks) => {
|
||||||
if (host) {
|
if (host) {
|
||||||
args.push(host);
|
args.push(host);
|
||||||
}
|
}
|
||||||
args.push(async (error) => {
|
const onError = (error) => {
|
||||||
if (error) {
|
if ('EADDRINUSE' === error.code) {
|
||||||
reject(error);
|
error.message = (
|
||||||
return;
|
`HTTP server couldn't connect: '${[host, port].join(':')}' already in use!`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
reject(error);
|
||||||
|
};
|
||||||
|
httpServer.on('error', onError);
|
||||||
|
args.push(async () => {
|
||||||
|
httpServer.off('error', onError);
|
||||||
await flecks.invokeSequentialAsync('@flecks/web/server.up', httpServer);
|
await flecks.invokeSequentialAsync('@flecks/web/server.up', httpServer);
|
||||||
const actualPort = 0 === port ? httpServer.address().port : port;
|
const actualPort = 0 === port ? httpServer.address().port : port;
|
||||||
debug(
|
debug(
|
||||||
|
|
|
@ -8,6 +8,15 @@ const {
|
||||||
export {configSource};
|
export {configSource};
|
||||||
|
|
||||||
export const hooks = {
|
export const hooks = {
|
||||||
|
'@flecks/core.starting': (flecks) => {
|
||||||
|
const {
|
||||||
|
host = 'production' === NODE_ENV ? '0.0.0.0' : 'localhost',
|
||||||
|
port,
|
||||||
|
public: httpPublic,
|
||||||
|
} = flecks.get('@flecks/web');
|
||||||
|
flecks.web.host = host;
|
||||||
|
flecks.web.public = httpPublic || [host, port].join(':');
|
||||||
|
},
|
||||||
'@flecks/web.routes': (flecks) => {
|
'@flecks/web.routes': (flecks) => {
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
@ -60,15 +69,8 @@ export const mixin = (Flecks) => class FlecksWithWeb extends Flecks {
|
||||||
constructor(runtime) {
|
constructor(runtime) {
|
||||||
super(runtime);
|
super(runtime);
|
||||||
if (!this.web) {
|
if (!this.web) {
|
||||||
const {
|
|
||||||
host = 'production' === NODE_ENV ? '0.0.0.0' : 'localhost',
|
|
||||||
port,
|
|
||||||
public: httpPublic,
|
|
||||||
} = runtime.config['@flecks/web'];
|
|
||||||
this.web = {
|
this.web = {
|
||||||
config: runtime['@flecks/web'],
|
config: runtime['@flecks/web'],
|
||||||
host,
|
|
||||||
public: httpPublic || [host, port].join(':'),
|
|
||||||
server: undefined,
|
server: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user