Sparta applications delegate
func main() responsibilities to one of Sparta’s Main entrypoints (Main, MainEx). This provides each application with some standard command line options as shown below:
$ go run main.go --help Simple Sparta application that demonstrates core functionality Usage: main [command] Available Commands: delete Delete service describe Describe service execute Execute explore Interactively explore service help Help about any command profile Interactively examine service pprof output provision Provision service version Display version information Flags: -f, --format string Log format [text, json] (default "text") -h, --help help for main --ldflags string Go linker string definition flags (https://golang.org/cmd/link/) -l, --level string Log level [panic, fatal, error, warn, info, debug] (default "info") -n, --noop Dry-run behavior only (do not perform mutations) -t, --tags string Optional build tags for conditional compilation -z, --timestamps Include UTC timestamp log line prefix
It’s also possible to add custom flags and/or custom commands to extend your application’s behavior.
These command line options are briefly described in the following sections. For the most up to date information, use the
--help subcommand option.
This simply deletes the stack (if present). Attempting to delete a non-empty stack is not treated as an error.
describe command line option produces an HTML summary (see graph.html for an example) of your Sparta service.
The report also includes the automatically generated CloudFormation template which can be helpful when diagnosing provisioning errors.
This command is used when the cross compiled binary is provisioned in AWS lambda. It is not (typically) applicable to the local development workflow.
explore option creates a terminal GUI that supports interactive exploration of lambda functions deployed to AWS. This ui recursively searches for all *.json files in the source tree to populate the set of eligible events that can be submitted.
profile command line option enters an interactive session where a previously profiled application can be locally visualized using snapshots posted to S3 and provided to a local pprof ui.
provision option is the subcommand most likely to be used during development. It provisions the Sparta application to AWS Lambda.
version option is a diagnostic command that prints the version of the Sparta framework embedded in the application.
$ go run main.go version INFO ════════════════════════════════════════════════ INFO ╔═╗┌─┐┌─┐┬─┐┌┬┐┌─┐ Version : 1.2.1 INFO ╚═╗├─┘├─┤├┬┘ │ ├─┤ SHA : b76b71d INFO ╚═╝┴ ┴ ┴┴└─ ┴ ┴ ┴ Go : go1.10 INFO ════════════════════════════════════════════════ INFO Service: MyHelloWorldStack-mweagle LinkFlags= Option=version UTC="2018-07-20T04:44:17Z" INFO ════════════════════════════════════════════════