Skip to content

Commit

Permalink
allow arbitrary paths to be passed for hot reloading (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfangl authored Dec 16, 2022
1 parent afe23d0 commit 233fcfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/localstack/awsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func resetListener(changeChannel <-chan bool, server *CustomInteropServer) {

}

func RunHotReloadingListener(server *CustomInteropServer, targetPaths []string, opts *LsOpts, ctx context.Context) {
if !opts.HotReloading {
func RunHotReloadingListener(server *CustomInteropServer, targetPaths []string, ctx context.Context) {
if len(targetPaths) == 1 && targetPaths[0] == "" {
log.Debugln("Hot reloading disabled.")
return
}
Expand Down
19 changes: 10 additions & 9 deletions cmd/localstack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import (
"os"
"runtime/debug"
"strconv"
"strings"
)

type LsOpts struct {
InteropPort string
RuntimeEndpoint string
RuntimeId string
InitTracingPort string
CodeDownloadUrl string
HotReloading bool
InteropPort string
RuntimeEndpoint string
RuntimeId string
InitTracingPort string
CodeDownloadUrl string
HotReloadingPaths []string
}

func GetEnvOrDie(env string) string {
Expand All @@ -38,8 +39,8 @@ func InitLsOpts() *LsOpts {
InteropPort: GetenvWithDefault("LOCALSTACK_INTEROP_PORT", "9563"),
InitTracingPort: GetenvWithDefault("LOCALSTACK_RUNTIME_TRACING_PORT", "9564"),
// optional or empty
CodeDownloadUrl: os.Getenv("LOCALSTACK_CODE_ARCHIVE_DOWNLOAD_URL"),
HotReloading: os.Getenv("LOCALSTACK_HOT_RELOADING_ENABLED") != "",
CodeDownloadUrl: os.Getenv("LOCALSTACK_CODE_ARCHIVE_DOWNLOAD_URL"),
HotReloadingPaths: strings.Split(GetenvWithDefault("LOCALSTACK_HOT_RELOADING_PATHS", ""), ","),
}
}

Expand Down Expand Up @@ -88,7 +89,7 @@ func main() {
if err != nil {
log.Fatalln(err)
}
go RunHotReloadingListener(interopServer, []string{"/var/task"}, lsOpts, fileWatcherContext)
go RunHotReloadingListener(interopServer, lsOpts.HotReloadingPaths, fileWatcherContext)

// start runtime init
go InitHandler(sandbox, GetEnvOrDie("AWS_LAMBDA_FUNCTION_VERSION"), int64(invokeTimeoutSeconds)) // TODO: replace this with a custom init
Expand Down

0 comments on commit 233fcfb

Please sign in to comment.