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

yum wkhtmltopdf causes deployment error. #2

Closed
porteaux opened this issue Jul 18, 2013 · 7 comments
Closed

yum wkhtmltopdf causes deployment error. #2

porteaux opened this issue Jul 18, 2013 · 7 comments

Comments

@porteaux
Copy link

first thanks for sharing this useful document to the global comunity. I have already installed git, gnuplot, and gsl packages. this is what my current config.ruby looks like:


These are things that make sense for any Ruby application

Install git in order to be able to bundle gems from git

packages

yum:
git: []
gnuplot: []
gsl: []

wkhtmltopdf: []

commands:

Run rake with bundle exec to be sure you get the right version

add_bundle_exec:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
command: perl -pi -e 's/(rake)/bundle exec $1/' 11_asset_compilation.sh

Bundle with --deployment as recommended by bundler docs

cf. http://gembundler.com/v1.2/rationale.html under Deploying Your Application

add_deployment_flag:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
command: perl -pi -e 's/(bundle install)/$1 --deployment/' 10_bundle_install.sh

Vendor gems to a persistent directory for speedy subsequent bundling

make_vendor_bundle_dir:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
command: mkdir /var/app/support/vendor_bundle

Store the location of vendored gems in a handy env var

set_vendor_bundle_var:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/support
command: sed -i '12iexport EB_CONFIG_APP_VENDOR_BUNDLE=$EB_CONFIG_APP_SUPPORT/vendor_bundle' envvars

The --deployment flag tells bundler to install gems to vendor/bundle/, so

symlink that to the persistent directory

symlink_vendor_bundle:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
command: sed -i '6iln -s $EB_CONFIG_APP_VENDOR_BUNDLE ./vendor/bundle' 10_bundle_install.sh

Don't run the above commands again on this instance

cf. http://stackoverflow.com/a/16846429/283398

z_write_post_provisioning_complete_file:
cwd: /opt/elasticbeanstalk/support
command: touch .post-provisioning-complete


when I uncomment:

wkhtmltopdf: []

And then deploy the new version to my eb app.

My eb console for the environment shows:

2013-07-18 09:55:36 UTC-0400 ERROR Failed to deploy application.
2013-07-18 09:55:35 UTC-0400 ERROR Responses from [i-59892133] were received, but the commands failed.
2013-07-18 09:55:22 UTC-0400 INFO Deploying new version to instance(s).

@gkop
Copy link
Owner

gkop commented Jul 18, 2013

This could fail for any number of reasons. I would investigate by ssh'ing into an instance and running $ yum install wkhtmltopdfto find the error.

Here's another project's config where they have to drop to commands to install certain yum packages: https://github.com/benjamind/delarre.docpad/blob/master/src/documents/posts/deploying-libcouchbase-with-aws-elasticbeanstalk.html.md#using-ebextensions-commands

@porteaux
Copy link
Author

No success with:

commands:
#install wkhtmltopdf
01-command:
command: yum install xz urw-fonts libXext openssl-devel libXrender
02-command:
command: wget http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltopdf-0.10.0_rc1-static-amd64.tar.lzma&can=2&q=
03-command:
command: xz -d wkhtmltopdf-0.10.0_rc1-static-amd64.tar.lzma
04-command:
command: tar -xvf wkhtmltopdf-0.10.0_rc1-static-amd64.tar
05-command:
command: cp wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf

or:

apt:
wkhtmltopdf: []

@gkop gkop closed this as completed Aug 12, 2013
@porteaux
Copy link
Author

I made that change en when the new commit is deployed the following message is shown:

[Instance: i-aff555d5 Module: AWSEBAutoScalingGroup ConfigSet: null] Failed on instance with return code: 1 Output: ver msg = "%s\n" % self.format(record) File "/usr/lib64/python2.6/logging/init.py", line 654, in format return fmt.format(record) File "/usr/lib64/python2.6/logging/init.py", line 436, in format record.message = record.getMessage() File "/usr/lib64/python2.6/logging/init.py", line 306, in getMessage msg = msg % self.args UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 366: ordinal not in range(128) Error occurred during build: Command 03-command failed .

@porteaux
Copy link
Author

This worked:

#install wkhtmltopdf
01-command:
command: yum install xz urw-fonts libXext openssl-devel libXrender
02-command:
command: wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2
03-command:
command: tar -xvf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2
04-command:
command: cp wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf

@nedyalkov
Copy link

@porteaux thank you very much for sharing your solution! It installed everything correctly, but I received "Cannot create a QPixmap when no GUI is being used" error. It seems that version 0.11.0_rc1 requires X to render opacity property.
That's why I tried the version pointed here - http://thelazylog.com/how-to-resolve-cannot-create-a-qpixmap-when-no-gui-is-being-used-when-running-wkhtmltopdf/ - 0.10.0_rc2
It works just fine on server without X 😄

@strabek
Copy link

strabek commented May 18, 2016

For the latest (0.12.3) version I got this working with below code:

03_command:
command: yum install xz urw-fonts libXext openssl-devel libXrender
04_command:
command: wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
05_command:
command: tar -xJf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
06_command:
command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
07_command:
command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage

Forgive me not having proper YAML format but I wasn't able to format 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

No branches or pull requests

5 participants