Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify HOST for express server to listen on #190

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Specify HOST for express server to listen on #190

wants to merge 6 commits into from

Conversation

DerOetzi
Copy link
Contributor

New pull request for feature request #168

@@ -224,6 +224,7 @@ if (app.get('env') === 'development') {

// App configuration for all environments
app.set('port', process.env.PORT || 3000);
app.set('host', process.env.HOST || '0.0.0.0');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about something like this, and remove the line setting this on the app?

  var server_params = {
            port :  process.env.PORT || 3000
        }
        
        if(process.env.HOST){
            server_params.host = process.env.HOST;
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any pros and cons to this change unless the configuration is needed elsewhere in the application. In addition, the possibility of setting a default value is lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, you can not view the configuration in the log

@DerOetzi
Copy link
Contributor Author

I have resolved some merge conflicts to master branch. Now it is possible to merge this pull requests.

@marziman
Copy link
Contributor

marziman commented Feb 7, 2022

@DerOetzi is this still relevant? I see no problem with this PR.

@DerOetzi
Copy link
Contributor Author

DerOetzi commented Feb 9, 2022

For me personally this isn't relevant anymore as I don't use openhab-cloud but using a vpn connection behind a haproxy setup. But I think for server admins which want there own cloud instance on a server with multiple IPs this is still a good feature.

@electraport
Copy link
Contributor

electraport commented Jun 11, 2022

Sorry for the thread necromancy but since it's still open, I have noticed after a batch of test installs that the server seems to come up listening on IPv6 only, and requires something similar to:

var server = app.listen(system.getNodeProcessPort(), '0.0.0.0', function () {
    logger.info('openHAB-cloud: express server listening on port ' + system.getNodeProcessPort());

in /app.js to listen on IPv4 - where I added the comma and '0.0.0,0' between system.getNodeProcessPort and the callback.

I can see the arguments for the ability to set a default in e.g. /config.json and am happy to put up a pr for this if you want it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants