yarn
with env variables
- CALLBACK_HOST — Internal API that called after screenshoting. default:
http://localhost:9002
- POOL_SIZE — Count of tabs in browser. default
require('os').cpus().length / 2
- QUEUE_NAME — Queue name in Rabbit. default
howtocards:render
- RABBIT_HOST — RabbitMQ server. default
amqp://localhost:5672
- RENDER_HOST — Howtocards Frontend instance. default
https://howtocards.io
- UPLOADER_HOST — Image Uploader internal API. default
http://localhost:4000
yarn start
to run workerCTRL+C
— shutdown worker
docker run -v `pwd`/the-files:/files -it -e "VOLUME=/files" --expose 4000 howtocards/image-uploader/image-uploader
Worker subscribes to tasks from QUEUE_NAME
at RABBIT_HOST
.
Task types:
{ "user": "@sergeysova", "extra": {}, "callback": "/preview/user/@sergeysova" }
— to render/@sergeysova
{ "card": "2", "extra": {}, "callback": "/preview/card/2" }
— to render/open/2
Steps:
-
Task received
-
Tab consumed from pool
-
Task rendered by specified type
user
just makes screenshot of user pagecard
makes screenshot of card, and get snapshot. Frontend should render with Slate
-
Tab returned to pool
-
Screenshot is uploaded to
UPLOADER_HOST
-
If
.callback
present send POST request to{CALLBACK_HOST}/{callback}
with JSON body{ "screenshot": "/abcd/efgh/asdasd.png", "snapshot": "<div></div>" }
- snapshot generated only for
card
user
sends only{"screenshot": ""}
screenshot
is a path relative tohttps://howtocards.io/images
- snapshot generated only for