miguelrgonzalez / mlsound

NPM-based application deployment tool for MarkLogic
Other
8 stars 5 forks source link

mlsound bootstrap fails on localhost #11

Open RobertSzkutak opened 8 years ago

RobertSzkutak commented 8 years ago

initializeHosts() fails on localhost.

On at least Windows, the hostname MarkLogic expects is not "localhost" but instead your "PC Name". For example, mine is "robpc.attlocal.net".

Changing all of the hostnames in the JSON configs from "localhost" fixes this. However, it would be nice to fix this properly within mlsound.

In my personal opinion, I think it's important to preserve the option to use localhost in the config files so that projects bootstrapped by mlsound can be easily swapped between developers without having to reconfigure them first.

dmcassel commented 8 years ago

I think this is not a Windows problem -- I think it's all platforms, based on MarkLogic wanting the hostname as MarkLogic knows it (as seen in http://localhost:8002/manage/v2/hosts).

grtjn commented 8 years ago

What kind of config are you trying to push?

RobertSzkutak commented 8 years ago

The default config from mlsound create.

grtjn commented 8 years ago

Hmm, it could be useful if the configs were a bit more adaptive, and would try to avoid host references as much as possible. If you then deploy against a cluster it could create forests on all, instead of only the ones named explicitly.. Would save a lot of typing..

Roxy added host support only in one of the latest releases, and most importantly to support re-assigning hosts to specific groups..

jmeekhof commented 8 years ago

I've been looking at this issue all day, and the way I'd like to approach fixing this issue would be to create a branch of logic that handles the 'local' call differently. Essentially I'd like the code to decide to make a call to the REST api to determine the host name if it's running in the local environment. I've found (so far) two places this could be done.

src/lib/database.js in the DBManager.prototype.initializeMultiObjects function. Here we could branch off and make a GET request to return the nameref as a return from http://localhost:8002/manage/v2/hosts/?format=json

OR

src/lib/common.js we could apply the same logic there in one of the various functions there that feeds database.js

My guess is that the change would make the most sense in common.js as a fix there will work elsewhere too.

Any suggestions or thoughts?

jmeekhof commented 8 years ago

After looking a bit deeper, common.js doesn't include the marklogic library which is what is used to make the REST calls, so that complicates making this change in common.js

grtjn commented 8 years ago

Personally I wouldn't special-case local, as the same issue occurs for non-local too. First thing is there is a difference between url to reach the bootstrap host, and host names of hosts. Second thing is, working with clusters with multiple groups is a pretty advanced use case. I'd say keep host config out of the base config altogether would at least make the simple case work out of the box. Advanced cluster setup will require a good way to refer to hosts, possible without using names..

miguelrgonzalez commented 8 years ago

Hi @jmeekhof / @RobertSzkutak, can you try again with the latest code? mlsound now will try a reverse DNS lookup when setting up the host via IP or as localhost.

I don't have a windows machine to test my changes, but I presume that should do the trick.