4

AWS Lambda はバイナリの実行をサポートしているため、AWS Lambda で実行したかったpdflatexのですが、いくつか問題が発生しました。私は他のバイナリを正常に実行しましたpdflatexが、多くの共有 OS ライブラリの依存関係があり、それを機能させる方法がわかりませんでした。

サンプル コードは次のようになります。

'use strict';
let exec = require('child_process').exec;

exports.handler = (event, context, callback) => {
  const child = exec('LD_LIBRARY_PATH=bin/ ./pdflatex my-file.tex', (error) => {
    callback(error, 'Process complete!');
  });
  child.stdout.on('data', console.log);
  child.stderr.on('data', console.error);
};

ZIP ファイルは次のようになります。

index.js -------------- where the above code is
pdflatex -------------- binary from my OS
my-file.tex ----------- a sample LaTeX document
bin/ ------------------ folder with shared OS libraries

アップロードされた ZIP ファイルには、上記のすべてが含まれています。

で生成しpdflatexましたcp $(which pdflatex) pdflatex

  1. これはそれをアップロードする正しい方法pdflatexですか?この方法に問題はありますか?より良い方法はありますか?

初めて実行しようとした後、AWS Lambda は多くlib_____.soが不足していると訴えたので、それらを自分のマシンからbin/ZIP 内のフォルダーにコピーしました。以前はの依存関係ldd $(which pdflatex)を探していました。pdflatex

しかし、さすがにAWS Lambdaが動くLinux版には対応していなかったので、CentOSを起動してlib______.soファイルをbin/フォルダにコピーしたのですが、これもうまくいきませんでした。

  1. pdflatex必要なすべての依存関係を含み、共有 OS ライブラリを必要とせずに実行される自己完結型のバージョンを「ダンプ」する方法はありますか?

  2. pdflatexAmazon Linux インスタンス内でコンパイルする必要がありますか? これを 64 ビット アーキテクチャでコンパイルし、コードを 32 ビット アーキテクチャで実行した場合、失敗しませんか?

4

1 に答える 1

7

The best way to generate binaries for use in a Lambda is to either copy or compile them on the same version of Linux that Lambda uses. Amazon has a list of AMI images here: http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html. Create an EC2 instance from one of those, install the packages, and copy the files into your zip as you've done.

For #2, you can simplify the dependencies by doing a static compile, but I wouldn't try that unless you're familiar with building packages from source. You'll need to compile with -static at the link stage.

于 2016-05-13T21:27:42.577 に答える