Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
charsleysa committed Feb 27, 2018
2 parents 9b1584f + 453c34a commit 892a36e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -263,6 +263,18 @@ Unlike Node.JS and Java, Python requires you to enable remote debugging in your

> Please note, due to a [open bug](https://github.com/Microsoft/vscode-python/issues/71) with Visual Studio Code, you may get a `Debug adapter process has terminated unexpectedly` error when attempting to debug Python applications with this IDE. Please track the [GitHub issue](https://github.com/Microsoft/vscode-python/issues/71) for updates.
#### Passing Additional Runtime Debug Arguments

To pass additional runtime arguments when debugging your function, use the environment variable `DEBUGGER_ARGUMENTS`. This will pass a string of arguments directly into the run command SAM Local uses to start your function.

For example, if you want to load a debugger like iKPdb at runtime of your Python function, you could pass the following as `DEBUGGER_ARGUMENTS`: `-m ikpdb --ikpdb-port=5858 --ikpdb-working-directory=/var/task/ --ikpdb-client-working-directory=/myApp --ikpdb-address=0.0.0.0`. This would load iKPdb at runtime with the other arguments you've specified. In this case, your full SAM local command would be:

```bash
$ DEBUGGER_ARGUMENTS="-m ikpdb --ikpdb-port=5858 --ikpdb-working-directory=/var/task/ --ikpdb-client-working-directory=/myApp --ikpdb-address=0.0.0.0" echo {} | sam local invoke -d 5858 myFunction
```

You may pass debugger arguments to functions of all runtimes.

### Connecting to docker network
Both `sam local invoke` and `sam local start-api` support connecting the create lambda docker containers to an existing docker network.

Expand Down
27 changes: 23 additions & 4 deletions runtime.go
Expand Up @@ -432,12 +432,17 @@ func (r *Runtime) getDebugEntrypoint() (overrides []string) {
if len(r.DebugPort) == 0 {
return
}
debuggerArgs := os.Getenv("DEBUGGER_ARGS")
debuggerArgsArray := strings.Split(debuggerArgs, " ")
switch r.Name {
// configs from: https://github.com/lambci/docker-lambda
// to which we add the extra debug mode options
case runtimeName.java8:
overrides = []string{
"/usr/bin/java",
}
overrides = append(overrides, debuggerArgsArray...)
overrides = append(overrides,
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=" + r.DebugPort,
"-XX:MaxHeapSize=1336935k",
"-XX:MaxMetaspaceSize=157286k",
Expand All @@ -447,32 +452,41 @@ func (r *Runtime) getDebugEntrypoint() (overrides []string) {
"-XX:-TieredCompilation",
"-jar",
"/var/runtime/lib/LambdaJavaRTEntry-1.0.jar",
}
)
case runtimeName.nodejs:
overrides = []string{
"/usr/bin/node",
}
overrides = append(overrides, debuggerArgsArray...)
overrides = append(overrides,
"--debug-brk=" + r.DebugPort,
"--nolazy",
"--max-old-space-size=1229",
"--max-new-space-size=153",
"--max-executable-size=153",
"--expose-gc",
"/var/runtime/node_modules/awslambda/bin/awslambda",
}
)
case runtimeName.nodejs43:
overrides = []string{
"/usr/local/lib64/node-v4.3.x/bin/node",
}
overrides = append(overrides, debuggerArgsArray...)
overrides = append(overrides,
"--debug-brk=" + r.DebugPort,
"--nolazy",
"--max-old-space-size=1229",
"--max-semi-space-size=76",
"--max-executable-size=153",
"--expose-gc",
"/var/runtime/node_modules/awslambda/index.js",
}
)
case runtimeName.nodejs610:
overrides = []string{
"/var/lang/bin/node",
}
overrides = append(overrides, debuggerArgsArray...)
overrides = append(overrides,
"--inspect=" + r.DebugPort,
"--debug-brk",
"--nolazy",
Expand All @@ -481,8 +495,13 @@ func (r *Runtime) getDebugEntrypoint() (overrides []string) {
"--max-executable-size=153",
"--expose-gc",
"/var/runtime/node_modules/awslambda/index.js",
)
case runtimeName.python27:
overrides = []string{
"/usr/bin/python2.7",
}
// TODO: also add debug mode for Python runtimes
overrides = append(overrides, debuggerArgsArray...)
overrides = append(overrides, "/var/runtime/awslambda/bootstrap.py")
}
return
}
Expand Down

0 comments on commit 892a36e

Please sign in to comment.