Skip to content

Commit 233fcfb

Browse files
authored
allow arbitrary paths to be passed for hot reloading (#8)
1 parent afe23d0 commit 233fcfb

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Diff for: cmd/localstack/awsutil.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ func resetListener(changeChannel <-chan bool, server *CustomInteropServer) {
213213

214214
}
215215

216-
func RunHotReloadingListener(server *CustomInteropServer, targetPaths []string, opts *LsOpts, ctx context.Context) {
217-
if !opts.HotReloading {
216+
func RunHotReloadingListener(server *CustomInteropServer, targetPaths []string, ctx context.Context) {
217+
if len(targetPaths) == 1 && targetPaths[0] == "" {
218218
log.Debugln("Hot reloading disabled.")
219219
return
220220
}

Diff for: cmd/localstack/main.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ import (
1111
"os"
1212
"runtime/debug"
1313
"strconv"
14+
"strings"
1415
)
1516

1617
type LsOpts struct {
17-
InteropPort string
18-
RuntimeEndpoint string
19-
RuntimeId string
20-
InitTracingPort string
21-
CodeDownloadUrl string
22-
HotReloading bool
18+
InteropPort string
19+
RuntimeEndpoint string
20+
RuntimeId string
21+
InitTracingPort string
22+
CodeDownloadUrl string
23+
HotReloadingPaths []string
2324
}
2425

2526
func GetEnvOrDie(env string) string {
@@ -38,8 +39,8 @@ func InitLsOpts() *LsOpts {
3839
InteropPort: GetenvWithDefault("LOCALSTACK_INTEROP_PORT", "9563"),
3940
InitTracingPort: GetenvWithDefault("LOCALSTACK_RUNTIME_TRACING_PORT", "9564"),
4041
// optional or empty
41-
CodeDownloadUrl: os.Getenv("LOCALSTACK_CODE_ARCHIVE_DOWNLOAD_URL"),
42-
HotReloading: os.Getenv("LOCALSTACK_HOT_RELOADING_ENABLED") != "",
42+
CodeDownloadUrl: os.Getenv("LOCALSTACK_CODE_ARCHIVE_DOWNLOAD_URL"),
43+
HotReloadingPaths: strings.Split(GetenvWithDefault("LOCALSTACK_HOT_RELOADING_PATHS", ""), ","),
4344
}
4445
}
4546

@@ -88,7 +89,7 @@ func main() {
8889
if err != nil {
8990
log.Fatalln(err)
9091
}
91-
go RunHotReloadingListener(interopServer, []string{"/var/task"}, lsOpts, fileWatcherContext)
92+
go RunHotReloadingListener(interopServer, lsOpts.HotReloadingPaths, fileWatcherContext)
9293

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

0 commit comments

Comments
 (0)