This will be used to power LilyBin, a pastebin for music based on LilyPond. It is written for AWS Lambda to allow for an unmatched on-demand scalability.
For each version of LilyPond desired, a separate Lambda function needs to be
created. The version is controlled by the version
file in the root directory.
The workflow of this Lambda function is like this:
Receive event payload from LilyBin core, in the scheme of:
{
"code": "this is the LilyPond source",
"id" : "this is the ID of the source"
}
cd
to /tmp
, the only writable storage.
Try to install LilyPond using install_lilypond.sh
:
/tmp/ly
exists. If so, assume LilyPond is already
installed, and skip to #4.s3://lilybin-tarballs/
)./tmp/ly
. PATH
and LD_LIBRARY_PATH
are modified.gs
) is monkey patched to avoid a
weird error regarding Fontmaps.Write the input file to input.ly
.
Execute LilyPond on it, outputting to rendered.pdf
, rendered.midi
, and
rendered*.png
. stderr
output is saved into a response object.
Do three things concurrently (uploadFiles
):
rendered.pdf
if it exists.rendered.midi
if it exists.rendered.png
.
<key>-page1.png
, and set pages
property in response object to 1.<key>-page*.png
.Report that the run succeeded (or failed) with the response object.
Some deployment helpers are available in deploy/
. These contain some details
about how my developement environment is set up so don't expect much out of
it :)
make-zipball.sh
makes a zipball of source files, as code.zip
.
create.sh
creates a new Lambda function with the generated zipball:
# deploy/create.sh <version>
deploy/create.sh unstable
deploy.sh
updates the source of an existing Lambda function:
# deploy/deploy.sh <version>
deploy/deploy.sh unstable
In tools/
there are some tools for checking and updating LilyPond tarballs.
check-new-version.sh
checks for the latest version of stable and unstable
LilyPond builds, output the release versions to versions.json, and prints
the distribution versions.make-tarball.sh
downloads a LilyPond binary and decompresses it to a vanilla
.tar
archive.
# recommended; renames the tarball
# to a form fit for uploading
# tools/make-tarball.sh <version> [<lilybin_version>]
tools/make-tarball.sh 2.18.2-1 stable
# --> lilypond-stable.linux-64.tar
upload-tarballs.sh
uploads all files matching lilypond-*.tar
to S3, and
versions.json
if it exists.update.sh
combines all of the above.test/
contains some non-automated tests.
When you have made some local changes, node local.js
is your friend. It
emulates the AWS Lambda API and tries to run your handler against a payload, in
payload.json
.
You might need to rm -rf /tmp/input.ly /tmp/rendered* /tmp/ly
if you want a
clean start.
If you have AWS CLI installed and configured properly, test/live.sh
can be
used to test a deployed instance. You have to manually modify func
variable
in the file to change function to test. (PR welcome)
Copyright © 2015 Tiancheng “Timothy” Gu.
MIT licensed.
See LICENSE.md
for the full license text.