Comments (7)
The select
option is in the wrong place in your manifest, so your root server object is being given to the plugin, hence the error and the need for you to select manually inside the plugin.
The plugin.options
object is reserved for the options passed directly to the plugin (i.e the second parameter in your exports.register
function). select
, prefix
etc need to go one level above i.e.:
//manifest.js
var manifest = {
connections:[
{
host: appname.host,
port: appname.port.web,
labels: ['web']
},
{
host: appname.host,
port: appname.port.client,
labels: ['app-client']
}
],
registrations: [
{
plugin: {
register:'../services/app-client',
options: {
something: 'else' // passed to plugin as options.something
}
},
options: {
select: ['app-client'] // used internally by hapi when registering plugin
}
}
]
};
If you don't need any plugin options, you can make it a bit more concise:
//manifest.js
var manifest = {
connections:[
{
host: appname.host,
port: appname.port.web,
labels: ['web']
},
{
host: appname.host,
port: appname.port.client,
labels: ['app-client']
}
],
registrations: [
{
plugin: '../services/app-client',
options: {
select: ['app-client']
}
}
]
};
from glue.
There's something definitely odd going on here still, even after I update to the concise code you describe. The server always exits immediately. If I log out server.connections
, I get 1 or 2, based on whether or not I apply the select
option... but server.listener
is always null
.
from glue.
The above works for me. Perhaps try to create a repo on here with a minimal example showing the problem and I'll take a look. It's hard to debug any further without seeing the full thing.
from glue.
I created a repo, and wound up discovering that my error was due to the use of port 80 on my mac, which requires the user to be running as root.
I spent 4 hours working through this, just to discover I should select a different port 😩
Side note, the server exits cleanly with a 0 exit code, even though it couldn't establish a connection, and even if I was using error handling.
from glue.
You need to check for the server.start()
error, which will be present if you're listening to a port you're not allowed, and throw it, you'll get a non-zero then:
const Glue = require('glue');
const manifest = {
connections:[ { port: 80 } ]
};
Glue.compose(manifest, { relativeTo: __dirname }, (err, server) => {
if (err) {
throw err;
}
server.start((err) => {
if (err) {
throw err; // check for me
}
});
});
Output from running:
$ node index.js
/Users/.../index.js:16
throw err;
^
Error: listen EACCES 0.0.0.0:80
at Object.exports._errnoException (util.js:837:11)
at exports._exceptionWithHostPort (util.js:860:20)
at Server._listen2 (net.js:1218:19)
at listen (net.js:1267:10)
at net.js:1376:9
at doNTCallback3 (node.js:440:9)
at process._tickCallback (node.js:346:17)
at Function.Module.runMain (module.js:477:11)
at startup (node.js:117:18)
at node.js:951:3
$ echo $?
1
from glue.
yup. you're right. I was only handling the Compose((err, server) => {})
error. It's been a long week already. There are days you catch these user mistakes in 10 minutes... and then days where it takes you 4 hours. :-)
from glue.
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.
from glue.
Related Issues (20)
- how do you pass in concurrent option to hapi? HOT 4
- Should we have a "ISSUE_TEMPLATE.md" for Glue? HOT 1
- How should I use routes in server config (failAction). HOT 3
- Add hook to transform plugin list before registration HOT 17
- Integration with webpack - dynamic import issue HOT 4
- Make hapi a peer dependency HOT 7
- Error: Cannot start server before plugins finished registration HOT 4
- Using glue with hapi-mongoose HOT 5
- server.events is undefined after glue compose HOT 5
- Server options load support? Migrating from hapi 16 -> 17 HOT 6
- Change module namespace HOT 1
- Change module namespace for v5 branch HOT 1
- Server cache options in hapi 18 cannot be passed HOT 3
- Action required: Greenkeeper could not be activated 🚨 HOT 1
- Update deps HOT 1
- Update joi HOT 1
- Add typescript type definitions HOT 2
- Only node 12
- No way of passing default route validator to glue HOT 1
- plugin.name is required
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glue.