-
Notifications
You must be signed in to change notification settings - Fork 18
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
(UndefinedFunctionError) function nil.node_count/0 is undefined (module nil is not available) #16
Comments
The first thing I would check is if the application was started able to load your database: iex(1)> Process.whereis(Geolix.Database.Supervisor)
#PID<0.139.0>
iex(2)> GenServer.call(Geolix.Database.Loader, :registered)
[:city, :country] Can you confirm the output of those calls? It might be the way you have stored your databases. For compressed databases it uses That should lead to a Enum.each(Application.get_env(:geolix, :database), &Geolix.load_database/1) That is be the problem I suspect at the moment... |
Hi! And thanks for your quick response:
And loading the database:
It seems that I don't get any error messages. Unfortunately, I have to leave now. But, will test again tomorrow using a zip compression instead of the tar.gz. I'll keep you posted! Thanks a lot for your assistance! And have a nice evening! |
Err, sorry, my bad -.- That should have been I will do some digging myself to see if I can reproduce this behaviour and maybe get a fix up and running. |
Missed the Enum.each, too ;-) Using Enum.map showed an actual error. I got it working by extracting the file and directly using "city.mmdb" file. So, my initial mistake was to download the files from here: For the city and country: And I was using these archives directly with geolix and assumed that's the way to go. Since don't work because they contain a directory with some readme and the db file. Additionally, now I tried to zip and also to tar.gz the "city.mmdb" file, which both don't work. How do you compress the files for yourself to make it work? What would you suggest in case of using your library on Heroku? I assume it won't work, because of the Heroku ephemeral filesystem. Would it be possible to make it so that your library downloads the db files from somewhere and keeps them in memory instead? |
The error being swallowed (probably But MaxMind having changed their download links (and compression/archive) is a different thing that implicates something else... Back in the days when the download was last changed there was a real "pure gzip" download location. As in just the database file and just gzipped. Directly usable by in-memory decompression. A tarball (and the new ones especially) will never work that way because they have folders and multiple files and things. So there are two ways for the database to be used:
The last one might be tricky to configure however. As the path in the archive seems to adjust to the "last build date", you might need some shell foo to have a predictable location (if not using an auto-updater from your system package manager): # not really tested, probably there are easier ways
# also depends on the "GNU" version of commands like sort
find . -name 'GeoLite-City.mmdb' \
| sort -rV \
| head -1 \
| xargs -I {} cp {} /path/to/GeoLite-City.mmdb That should find the newest file (by the date of the folder) and copy the database there to a custom location. Something like that in your The only way of using "direct download" files is by providing an URL for it (see Remote Files Configuration). You could use Everything more would include some real package management and that is somewhat out of scope here. At least out of scope of the main library, there might be a use of a specific "download and update database application"... |
After digging through the |
Great - that you found the error swallow! I've tested it again and used gzip on the mmdb files directly and everything works as expected now! Awesome! After some more research, it found that some people use Heroku buildpacks for example: https://github.com/Shopify/heroku-buildpack-geoip. The build pack is then downloading and extracting everything. Just have to make sure that you deploy on a regular basis, so the build pack is re-downloading a fresh db. Totally understand that you don't want to include the update db stuff in your package 👍 I'm not 100% certain that using an in memory approach makes sense here, yet. Would have to think more about it. But, if it's a quick win for you which does offer another option to deploy things more easily - why not ;-) Thank you so much for assisting me here :-) |
Thanks for working on this library - just what I was looking for!
I seem to run into a problem when doing a lookup, like this:
My guess is that it's just a configuration problem on my side. Following the complete error message:
And this is my configuration:
Hope that gives you enough information to help me get things running. Thanks a lot in advance!
The text was updated successfully, but these errors were encountered: