hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

Server options load support? Migrating from hapi 16 -> 17 #123

Closed eitah closed 5 years ago

eitah commented 5 years ago

I'm migrating from hapi 16 -> 17.

I see the new syntax for passing load options in hapi is to pass server.options.load (example max event loop delay as documented here https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsload). The docs above label it as the Hapi api for v18.x but since that’s the development version I think the settings are identical for v17 as per the release notes here hapijs/hapi#3658

But when i try to pass those in my manifest options the Joi schema dings me for not being one of the options below. would there be plans to include additional happy config options in glue eventually? Or how would you recommend I pass options to the hapi Server outside of those supported by glue?

We're on node 8 and Express if that matters. Thanks, Eli

relativeTo: Joi.string(),
preRegister: Joi.func().allow(false)
csrl commented 5 years ago

Server options go into manifest.server, not glue compose options. If that is what you are doing, then please provide example code that fails.

eitah commented 5 years ago

I am following along with the example usage here https://github.com/hapijs/glue/blob/master/API.md#usage

that code abstracts away access to the call to this code so that I never write the line const server = Hapi.server({ cache: [{ engine: require('redis') }], port: 8000 });

I dont understand how to access the Hapi.server options object to pass additional options if glue compose returns an instance of a server already prepared.

eitah commented 5 years ago

To be specific about my code, i am passing manifest with the below options, and Hapi complains that they are not valid

const manifest = { server: { maxHeapUsedBytes: 1073741824, load: { sampleInterval: 1000, }, }, };

The error I receive is [1] "maxHeapUsedBytes" is not allowed at [relative path]/node_modules/hapi/lib/config.js:22:10)

If it matters sine hapi is complaining I am on version hapi@^17.8.1

csrl commented 5 years ago

Does it work with calling Hapi.server({ load: { sampleInterval: 1000, maxHeapUsedBytes: 1073741824, }, }) directly? As you show, the error comes from hapi, not glue.

eitah commented 5 years ago

that did it! thank you for the correction. I merely had the options object configured incorrectly. The heap should have been inside the load object not outside it. Thanks again.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.