From b14d239ebb72768e72a1c2abeda903b839aeb7df Mon Sep 17 00:00:00 2001 From: Dainius Jocas Date: Sat, 21 Mar 2020 21:17:57 +0200 Subject: [PATCH] Support AWS Lambda custom runtime (#305) * environment variable to disable handling of SIGPIPE * rename env variable to BABASHKA_DISABLE_PIPE_HANDLER --- README.md | 4 ++++ src/babashka/main.clj | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fc024b1..14968b21 100644 --- a/README.md +++ b/README.md @@ -1104,6 +1104,10 @@ $ docker run --rm script 1 2 3 Your command line args: (1 2 3) ``` +## Package babashka script as a AWS Lambda + +AWS Lambda runtime doesn't support signals, therefore babashka has to disable handling of the SIGPIPE. This can be done by setting `BABASHKA_DISABLE_PIPE_HANDLER` to `true`. + ## Thanks - [adgoji](https://www.adgoji.com/) for financial support diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 3f9d1d37..2e6ec6b6 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -289,7 +289,8 @@ Everything after that is bound to *command-line-args*.")) (defn main [& args] - (handle-pipe!) + (when-not (Boolean/valueOf ^String (System/getenv "BABASHKA_DISABLE_PIPE_HANDLER")) + (handle-pipe!)) #_(binding [*out* *err*] (prn "M" (meta (get bindings 'future)))) (binding [*unrestricted* true]