Pyjoyment.Command.lambda - AWS Lambda command¶
Usage: APPLICATION lambda [OPTIONS]
handler = app.start('lambda')
Options:
-h, --help Show this summary of available options
--home <path> Path to home directory of your application,
defaults to the value of PYJO_HOME or
auto-detection
--log-format <name> Format of log messages, "text", "plain" without
time and process, or "json", defaults to the
value of PYJO_LOG_FORMAT or "text"
-m, --mode <name> Operating mode for your application, defaults to
the value of PYJO_MODE or "development"
Pyjoyment.Command.lambda starts applications with the
Pyjo.Server.Lambda backend: it returns the handler of an event
function of AWS Lambda, which a script keeps for the runtime that imports it.
The script of an application that ends with handler = app.start(), as
myapp.py with the handler myapp.handler, runs this command in the
runtime of AWS Lambda, which has the AWS_LAMBDA_RUNTIME_API environment
variable, and the command of its arguments otherwise.
The script that runs as the main program with that variable, as the
bootstrap of a custom runtime or the command of an image, is the runtime
itself: the command runs the application for the invocations of the Runtime
API with Pyjo.Server.Lambda.Pyjo_Server_Lambda.run_runtime(), until the
process ends, where a runtime that imports the script takes its handler.
#!/bin/sh
# The bootstrap of a custom runtime, as provided.al2023
exec python3 "$LAMBDA_TASK_ROOT/myapp.py"
This is a core command, that means it is always enabled and its code a good example for learning to build new commands, you’re welcome to fork it.
See Pyjoyment.Commands for a list of commands that are available by
default.
See also¶
Classes¶
- class Pyjoyment.Command.lambda.Pyjoyment_Command_lambda(**kwargs: Any)[source]¶
Pyjoyment.Command.lambdainherits all attributes and methods fromPyjoyment.Commandand implements the following new ones.- description = 'Start application with AWS Lambda'¶
description = command.description command.description = 'Foo'
Short description of this command, used for the command list.
- usage = 'Usage: APPLICATION lambda [OPTIONS]\n\n handler = app.start(\'lambda\')\n\nOptions:\n -h, --help Show this summary of available options\n --home <path> Path to home directory of your application,\n defaults to the value of PYJO_HOME or\n auto-detection\n --log-format <name> Format of log messages, "text", "plain" without\n time and process, or "json", defaults to the\n value of PYJO_LOG_FORMAT or "text"\n -m, --mode <name> Operating mode for your application, defaults to\n the value of PYJO_MODE or "development"\n'¶
usage = command.usage command.usage = 'Foo'
Usage information for this command, used for the help screen.