anmonteiro / aws-lambda-ocaml-runtime Goto Github PK
View Code? Open in Web Editor NEWAn OCaml custom runtime for AWS Lambda and Vercel
License: BSD 3-Clause "New" or "Revised" License
An OCaml custom runtime for AWS Lambda and Vercel
License: BSD 3-Clause "New" or "Revised" License
For people who want to try out their lambdas locally
Rust runtime implemented it in awslabs/aws-lambda-rust-runtime#628
currently Lambda_runtime.start
is:
(Yojson.Safe.json -> Context.t -> (Yojson.Safe.json, string) result) -> unit
I think we might need to provide a Lambda_runtime.start_async
or start_io
that is:
(Yojson.Safe.json -> Context.t -> (Yojson.Safe.json, string) result Io.t) -> unit
where Io.t
is either Lwt.t
or Async.Deferred.t
to allow for async handlers.
hi @anmonteiro, looking forward to using this library. what's the best way to include this library in my project as i don't see it published on opam?
Right now the client is not exposed in the .mli
file but perhaps we should do it if people wanna build their own modified runtime?
Hi there. I'm trying to spin up a lambda function, but when I run the build.sh
file (after adapting the build.sh
and Dockerfile
scripts to my project -- basically just removing the examples/basic/
stuff), I get the following error:
failed to compute cache key: "/esy.lock" not found: not found
I'm happy to provide more details if needed. But is there any quick fix for this that comes to mind? Thanks so much for the work on this project.
Hi @anmonteiro
Do you have an idea as to why I receive this error from my basic lambda? I've changed the build.sh
to build with only dune without docker. Although it's likely my build script is incorrect now and is the root issue of this, the basic example doesn't work as-is because it lacks the esy.json
and esy.lock
file that the dockerfile expects.
{
"errorMessage": "RequestId: 5489ab76-43af-4303-9ec8-9984e5ae7c44 Error: fork/exec /var/task/bootstrap: exec format error",
"errorType": "Runtime.InvalidEntrypoint"
}
#!/usr/bin/env sh
set -eo pipefail
root_path=$PWD
# Start in examples/basic/ even if run from root directory
cd "$(dirname "$0")"
rm -rf bootstrap
# possible that this is the issue because i left out --profile=static
dune build basic.exe
mv ../../_build/default/examples/basic/basic.exe ./bootstrap
zip -j ./ocaml.zip bootstrap
cd $root_path
I'm using Linux, 5.3.5-arch1-1-ARCH. And tried to build the basic example. It went as this:
$ cd aws-lambda-ocaml-runtime/examples/basic
$ ./build.sh
Errors as:
Full log: https://gist.github.com/superherointj/9849fb617e9a62348f8211dbf6e3bf66
Brief Esy start log:
Step 18/26 : RUN echo ' { "name": "package-base", "dependencies": { "ocaml": "4.9.0", "@opam/dune": "*" } } ' > esy.json
---> Using cache
---> 41501f5c6966
Step 19/26 : RUN esy
---> Running in 07e224fcc0d8
ESC[91minfo esy 0.5.8 (using esy.json)
ESC[0mESC[91minfo checking https://github.com/ocaml/opam-repository for updates...
ESC[0mESC[91minfo checking https://github.com/esy-ocaml/esy-opam-override for updates...
ESC[0mESC[91minfo resolving esy packages: done
ESC[0mESC[91m/esy/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe: /usr/lib/libstdc++.so.6: no version information available (required by /esy/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe)
/esy/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe: /usr/lib/libstdc++.so.6: no version information available (required by /esy/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe)
/esy/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe: /usr/lib/libstdc++.so.6: no version information available (required by /esy/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe)
ESC[0mESC[91minfo solving esy constraints: done
ESC[0mESC[91minfo resolving npm packages: done
ESC[0mESC[91minfo fetching: done
ESC[0mESC[91minfo installing: done
ESC[0mESC[91minfo building @esy-ocaml/[email protected]@d41d8cd9
ESC[0mESC[91minfo building [email protected]@d41d8cd9
ESC[0mESC[91merror: build failed with exit code: 1
build log:
# esy-build-package: building: [email protected]
# esy-build-package: pwd: /root/.esy/3__________________________________________________________________________/b/ocaml-4.9.0-031bf83c
# esy-build-package: running: './esy-configure' '--disable-cfi' '--prefix' '/root/.esy/3__________________________________________________________________________/s/ocaml-4.9.0-031bf83c'
[esy-configure] Detected OSX / Linux environment
configure: Configuring OCaml version 4.09.0
[
<!---- There is more logs! --->
Middle logs are hidden but available from: https://gist.github.com/superherointj/9849fb617e9a62348f8211dbf6e3bf66
Brief end of logs:
stat: can't read file system information for '%m': No such file or directory
stat: can't read file system information for '%m': No such file or directory
tools/check-parser-uptodate-or-warn.sh: line 48: arithmetic syntax error
make[4]: *** [Makefile:1079: parsing/parser.ml] Error 2
make[4]: *** Waiting for unfinished jobs....
make[4]: Leaving directory '/root/.esy/3__________________________________________________________________________/b/ocaml-4.9.0-031bf83c'
make[3]: *** [Makefile:355: coreall] Error 2
make[3]: Leaving directory '/root/.esy/3__________________________________________________________________________/b/ocaml-4.9.0-031bf83c'
make[2]: *** [Makefile:362: core] Error 2
make[2]: Leaving directory '/root/.esy/3__________________________________________________________________________/b/ocaml-4.9.0-031bf83c'
make[1]: *** [Makefile:415: opt.opt] Error 2
make[1]: Leaving directory '/root/.esy/3__________________________________________________________________________/b/ocaml-4.9.0-031bf83c'
make: *** [Makefile:468: world.opt] Error 2
error: command failed: './esy-build' (exited with 2)
esy-build-package: exiting with errors above...
building [email protected]
esy: exiting due to errors above
**The command '/bin/sh -c esy' returned a non-zero code: 1**
File "tools/check-parser-uptodate-or-warn.sh" is available at
https://github.com/ocaml/ocaml/blob/trunk/tools/check-parser-uptodate-or-warn.sh
stat: can't read file system information for '%m': No such file or directory
tools/check-parser-uptodate-or-warn.sh: line 48: arithmetic syntax error
What did I do wrong? :-)
I'd like to try this out, but unsure about a way to add it as a dependency. I'd be fine using esy nix or opam to install it, but I'm not good enough at any of them to figure out immediately how to go about that.
Hey !
It seems we had the same idea https://github.com/vanwalj/aws-lambda-ocaml ! :D
I'm quite new to Ocaml, so i'm not sure what to expect but my handler seems pretty slow.
I get between 30 and 100ms (most of the time around 50ms) response time once the lambda is warmed up.
Did you notice something similar ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.