README ¶
Lazyraster
A caching PDF rasterizer that uses a filecache and a hashring to distribute load.
MuPDF is the PDF engine that drives the rasterizer.
License Restriction
This project is released under an MIT license, but it relies on the AGPL code from lazypdf. Therefore, running it must comply with the terms and conditions from this license. Sorry about that!
Building It
You MUST first install and build LazyPdf
This requires some C library dependencies that are not vendored in this
project. Install it in the correct location in your GOPATH
so that it
can be found in the correct location when building this project.
Once that is installed, if you have not already, you will need to install
all of the dependencies in vendor/
. This project uses the dep
tool to manage
dependencies. You must have that installed:
go get github.com/golang/dep/cmd/dep
Installing the dependencies is:
dep ensure
You can then build this project builds with a simple go build
.
Running It
Simply call the executable. By default, it will run on port 8000 and serve pdfs located in the current directory. Configuration is done using environment variables. These include the following:
RASTER_BASE_DIR
: The location where cached files are to be stored and served (default.
)RASTER_HTTP_PORT
: The port to listen on for HTTP connections (default8000
)RASTER_ADVERTISE_HTTP_PORT
: The advertised host port which gets mapped to RASTER_HTTP_PORT (default8000
)RASTER_AWS_REGION
: The AWS Region fallback to use when S3 region lookup fails (defaultus-west-1
)RASTER_CLUSTER_SEEDS
: The seeds to use to start the gossip ringRASTER_CACHE_SIZE
: The number of file objects to cache on disk at any one time. (default512
)RASTER_REDIS_PORT
: The port on which to serve Redis protocol traffic (default6379
)RASTER_CLUSTER_NAME
: The name of the Memberlist cluster (defaultdefault
)RASTER_RING_TYPE
: Usesidecar
ormemberlist
backing for hash ring? (default:sidecar
)RASTER_ADVERTISE_MEMBERLIST_HOST
: The IP / hostname advertised by MemberlistRASTER_ADVERTISE_MEMBERLIST_PORT
: The port advertised by Memberlist (default7946
)RASTER_SIDECAR_URL
: The Sidecar state URL (default:http://192.168.168.168:7777/api/state.json
)RASTER_SIDECAR_SERVICE_NAME
: The name to lookup in Sidecar when using Sidecar backing (defaultlazyraster
)RASTER_SIDECAR_SERVICE_PORT
: The port to lookup in Sidecar when using Sidecar backing (default10110
)RASTER_URL_SIGNING_SECRET
: A secret to use when validating signed URLs (default:deadbeef
). Set it to empty string to disable signature validation.RASTER_RASTER_CACHE_SIZE
: The number of Rasterizer objects to cache in memory at any one time (default20
)RASTER_RASTER_BUFFER_SIZE
: The maximum number of raster requests to queue (default10
)RASTER_LOGGING_LEVEL
: The cut off level for log messages. (debug
,info
,warn
,error
, defaultinfo
)
In addition, the AWS APIs will require authorization in the form of the standard AWS environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
If you are a New Relic customer and wish to monitor this using New Relic's service, the service includes the Gorelic platform agent. This is currently used in place of the New Relic go agent due to major licensing issues with the current Go agent. You may trigger the use of the New Relic agent by starting the service with:
NEW_RELIC_LICENSE_KEY
: the value is your current license key.SERVICE_NAME
: the name of the application in New Relic (e.g. 'foo-service')ENVIRONMENT_NAME
: appended toSERVICE_NAME
(e.g. 'foo-service-prod')
Local Development
If you are running this locally for development purposes, you will probably want to use the following options to get started:
$ RASTER_RING_TYPE=memberlist RASTER_LOGGING_LEVEL=debug ./lazyraster
This will use the Memberlist clustering library and not require an external Sidecar service discovery system. It will also enable debug logging level which can help in understanding where things went wrong.
Copyright
Copyright (c) 2017-2018 Nitro Software.
Documentation ¶
There is no documentation for this package.