nanobox-io / nanobox-pkgsrc-base

base pkgsrc packages for /data prefix
MIT License
6 stars 4 forks source link

MagicWand extra_packages request #15

Closed elbow-jason closed 7 years ago

elbow-jason commented 7 years ago

Could you please add the following packages to Nanobox pkgsrc?

Thank you!

Note: for use with Python wand lib. http://docs.wand-py.org/

elbow-jason commented 7 years ago

Here is the error that I am getting:

[2017-10-02 20:42:18 +0000] [94] [INFO] Starting gunicorn 19.7.1
[2017-10-02 20:42:18 +0000] [94] [INFO] Listening at: http://0.0.0.0:8080 (94)
[2017-10-02 20:42:18 +0000] [94] [INFO] Using worker: sync
[2017-10-02 20:42:18 +0000] [97] [INFO] Booting worker with pid: 97
[2017-10-02 20:42:19 +0000] [97] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/data/lib/python3.6/site-packages/wand/api.py", line 180, in <module>
    libraries = load_library()
  File "/data/lib/python3.6/site-packages/wand/api.py", line 135, in load_library
    raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
    worker.init_process()
  File "/data/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/data/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/data/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/data/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/data/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/data/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
    __import__(module)
  File "/app/server.py", line 4, in <module>
    from imager import imaging
  File "/app/imager/imaging.py", line 5, in <module>
    from wand.image import Image
  File "/data/lib/python3.6/site-packages/wand/image.py", line 20, in <module>
    from .api import MagickPixelPacket, libc, libmagick, library
  File "/data/lib/python3.6/site-packages/wand/api.py", line 206, in <module>
    'Try to install:\n  ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
  apt-get install libmagickwand-dev
[2017-10-02 20:42:19 +0000] [97] [INFO] Worker exiting (pid: 97)
[2017-10-02 20:42:19 +0000] [94] [INFO] Shutting down: Master
[2017-10-02 20:42:19 +0000] [94] [INFO] Reason: Worker failed to boot.
notxarb commented 7 years ago

Does OSError: cannot find library; tried paths: [] mean that the list of paths to try is empty?

Do you know if there's a way to populate that list?

libmagickwand should be part of the ImageMagick or ImageMagick6 package.

elbow-jason commented 7 years ago

my boxfile.yml:

run.config:
  engine: python
  engine.config:
    runtime: python-3.6
  # add nginx package
  extra_packages:
    - nginx
    - freetype2-2.7.1
    - ImageMagick

web.main:
  start:
    nginx: nginx -c /app/etc/nginx.conf
    python: gunicorn -c /app/etc/gunicorn.py server:app

Inside my box I ran:

pkgin in ImageMagick6 and hit Y to confirm installation

To start my app locally I ran:

MAGICK_HOME=/data gunicorn --bind=0.0.0.0:8080 server:app

And the server is up and running, and processing images as intended.

elbow-jason commented 7 years ago

This fix action was hinted at in this issue: https://github.com/dahlia/wand/issues/141

elbow-jason commented 7 years ago

After setting the local evars with:

nanobox evar add local MAGICK_HOME=/data

I was able to start the server from outside nanobox in the normal manner with:

nanobox run gunicorn --bind=0.0.0.0:8080 server:app

elbow-jason commented 7 years ago

@notxarb Will this fix action work in/transfer to a deploy?

elbow-jason commented 7 years ago

Does not work when deploying a dry-run. I get the original error except now the error reads:

Tue Oct 03 17:07:27 2017 web.main (python[daemon]) ::  OSError: cannot find library; tried paths: ['/data/lib/libMagickWand.so', '/data/lib/libMagickWandHDRI.so', '/data/lib/libMagickWandHDRI-2.so', '/data/lib/libMagickWand-6.so', '/data/lib/libMagickWand-6HDRI.so', '/data/lib/libMagickWand-6HDRI-2.so', '/data/lib/libMagickWand-Q16.so', '/data/lib/libMagickWand-Q16HDRI.so', '/data/lib/libMagickWand-Q16HDRI-2.so', '/data/lib/libMagickWand-Q8.so', '/data/lib/libMagickWand-Q8HDRI.so', '/data/lib/libMagickWand-Q8HDRI-2.so', '/data/lib/libMagickWand-6.Q16.so', '/data/lib/libMagickWand-6.Q16HDRI.so', '/data/lib/libMagickWand-6.Q16HDRI-2.so']
danhunsaker commented 7 years ago

Did you set MAGICK_HOME=/data in dry-run?

elbow-jason commented 7 years ago

yep.

nanobox evar ls dry-run

Environment Variables
  APP_NAME = sim
  HOARDER_HOST = 172.21.0.43
  LOGVAC_HOST = 172.21.0.41
  MAGICK_HOME = /data
  MIST_HOST = 172.21.0.42
  PORTAL_HOST = 172.21.0.40
danhunsaker commented 7 years ago

So from the sound of it, you had to install ImageMagick6 as well in order to get things working. If that's the case, ismply listing both versions in your extra_packages should do the trick.

elbow-jason commented 7 years ago

Rock on, @danhunsaker! It's working for a dry-run!

elbow-jason commented 7 years ago

And it's deployed to the interwebs.

So the fix for this issue was:

1) Include both ImageMagick and ImageMagick6 in extra_packages of the boxfile.yml like this:

run.config:
  engine: python
  engine.config:
    runtime: python-3.6
  # add nginx package
  extra_packages:
    - nginx
    - freetype2-2.7.1
    - ImageMagick
    - ImageMagick6

web.main:
  start:
    nginx: nginx -c /app/etc/nginx.conf
    python: gunicorn -c /app/etc/gunicorn.py server:app

2) And put the env var MAGICK_HOME=/data into the nanobox evars for your envs like this:

nanobox evar add dry-run MAGICK_HOME=/data

Additionally, I have destroyed the nanobox I was working with originally to ensure this process works from scratch.

Closing...