GithubHelp home page GithubHelp logo

Comments (7)

mtharrison avatar mtharrison commented on September 26, 2024

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.

LongLiveCHIEF avatar LongLiveCHIEF commented on September 26, 2024

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.

mtharrison avatar mtharrison commented on September 26, 2024

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.

LongLiveCHIEF avatar LongLiveCHIEF commented on September 26, 2024

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.

mtharrison avatar mtharrison commented on September 26, 2024

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.

LongLiveCHIEF avatar LongLiveCHIEF commented on September 26, 2024

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.

lock avatar lock commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.