-
Notifications
You must be signed in to change notification settings - Fork 163
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
Docs for using node-mapnik on AWS lambda #863
Comments
Edited: This seems to be a Cloud 9 issue and not a lambda issue This works great for basic mapnik. My data is stored in postgres. Any ideas how to get the plugins to work. Mapnik LOG> 2018-07-18 21:54:27: Problem loading plugin library: /home/ec2-user/environment/serverless/packages/aip-maps/node_modules/mapnik/lib/binding/lib/mapnik/input/pgraster.input (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI) |
@hwernstrom what is the output of:
Also what is the error if you try to open one of the plugins with the python ctypes module like described at https://github.com/mapnik/node-mapnik/wiki/Troubleshooting#the-specified-module-cannot-be-found? |
This appears to be an issue with the Cloud9 env, this works fine in lambda. I'm using Cloud9 as my dev because I thought it would closely match Lambda. Here are the results from Clould9. /home/ec2-user/environment/serverless/packages/aip-maps/node_modules/mapnik/lib/binding/lib/mapnik/input/pgraster.input: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/ec2-user/environment/serverless/packages/aip-maps/node_modules/mapnik/lib/binding/lib/mapnik/input/pgraster.input) |
Just fyi, on google cloud functions, I was able to use this with no extra steps. So great job folks. |
Is this still the recommended way to do this or is there more to be done? Initially I had issues with libmapnik.so.4.0 not existing, so as part of my lambda deploy process I cp libmapnik.so to libmapnik.so.4.0 from within the node_modules/mapnik/lib/binding/lib directory. This dir is then set as an environment variable in lambda as LD_LIBRARY_PATH. However I'm getting the following errors in the lambda logs:
I'm new to the lambda/mapnik and OSM game so any advice to getting mapnik running in aws lambda would be great. Thanks! |
@ScottSmudger I had to add libcrypt.so.1 to the zip to get the postgres stuff to work for me... grabbed it out of /lib64/ from the "Amazon Linux 2" ami |
I'm having the same issue. Seems it's only related to Error message in Lambda:
Pseudocode,
|
@knutole try using |
@springmeyer Thanks. I'm getting different results? Using python:3 Docker image: knutole@knutole ~/m/m/nodejs> docker run -it -v $PWD:/opt/nodejs -w /opt/nodejs python:3 python3
Python 3.8.1 (default, Jan 3 2020, 22:44:00)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL('node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input')
<CDLL 'node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input', handle 55ea4c5e3830 at 0x7f631b01cc70> Using OSX python 2: Python 2.7.16 (default, Dec 21 2020, 23:00:36)
[GCC Apple LLVM 12.0.0 (clang-1200.0.30.4) [+internal-os, ptrauth-isa=sign+stri on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL('mapnik/lib/binding/lib/mapnik/input/postgis.input')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 366, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(mapnik/lib/binding/lib/mapnik/input/postgis.input, 6): no suitable image found. Did find:
mapnik/lib/binding/lib/mapnik/input/postgis.input: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
/Users/knutole/mile-lambda/mapnik-layer/nodejs/node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 |
@springmeyer Do you have any suggestions of I'm not sure if the |
@knutole a couple thoughts:
|
@springmeyer Thanks again. I've added Python3 to the offical FROM lambci/lambda:build-nodejs12.x
RUN yum install -y python3 Running it, all seems well? knutole@knutole ~/m/m/nodejs> docker run -it -v $PWD:/opt/nodejs -w /opt/nodejs lambda-nodejs12-python3:latest python3
Python 3.7.9 (default, Feb 18 2021, 03:10:35)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-12)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL('node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input')
<CDLL 'node_modules/mapnik/lib/binding/lib/mapnik/input/postgis.input', handle ca6810 at 0x7ff583f894d0> I wonder why it's only PS: nodejs6 is already EOL on Lambda. :/ @springmeyer I've built and run the code on a local
but Any way to get more debugging info? CI build logs? Anything?? Perhaps it's got something to do with some dependencies only |
Brilliant solution that works, here: #937 (comment)! 💯 Thanks again for your time, @springmeyer. For future reference: I built |
Super!!! |
As of the v3.7.0 release (per #839) the node-mapnik binaries for linux work on AWS lambda. We should have some brief docs on how to install on lambda. The one gocha is that you need to match the right node version otherwise you'll get and error on lambda at startup like:
This is fixable by ensuring that you either:
Install locally on a linux machine with the same node version you are targeting on lambda, or;
You "cross-install"
Cross-installing is passing specific flags to
npm install
that explicitly selectlinux
as the operating system and an explicit node version you want to target. For more details see https://github.com/mapbox/node-pre-gyp#options.For example, to install a binary for lambda using node v6 on OS X do:
Note: this binary, while installable on OS X, is not going on run on OS X. The idea is that it will run on AWS lambda. If you tried to run it on OS X you'd see
dlopen(/Users/dane/projects/tilelive-bridge/node_modules/mapnik/lib/binding/mapnik.node, 1): no suitable image found.
since it is a linux binary.The text was updated successfully, but these errors were encountered: