Skip to content

Commit bf70931

Browse files
committed
Minor fixes
1 parent 3dea53e commit bf70931

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ Register a function `func` from example python code (the handler is formatted li
7373

7474
Register a function `func` from example javascript code (the handler is formatted like this: $(filename) and the name of the function is "handler"):
7575

76-
$ bin/serverledge-cli create -f func --memory 600 --src examples/hello.js --runtime nodejs17 --handler "hello"
77-
$ bin/serverledge-cli create -f func --memory 600 --src examples/inc.js --runtime nodejs17 --handler "inc"
76+
$ bin/serverledge-cli create -f func --memory 600 --src examples/hello.js --runtime nodejs17ng --handler "hello"
77+
$ bin/serverledge-cli create -f func --memory 600 --src examples/inc.js --runtime nodejs17ng --handler "inc"
7878

7979
Invoke `func` with arguments `a=2` and `b=3`:
8080

internal/api/api.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,20 @@ func CreateOrUpdateFunction(c echo.Context) error {
140140
return err
141141
}
142142

143+
var isUpdate bool
144+
143145
if c.Path() != "/update" {
144146
_, ok := function.GetFunction(f.Name) // TODO: we would need a system-wide lock here...
145147
if ok {
146148
log.Printf("Dropping request for already existing function '%s'\n", f.Name)
147149
return c.String(http.StatusConflict, "")
148150
}
149151

152+
isUpdate = false
150153
log.Printf("New request: creation of %s\n", f.Name)
151154
} else {
152155
log.Printf("New request: creation/update of %s\n", f.Name)
156+
isUpdate = true
153157
}
154158

155159
// Check that the selected runtime exists
@@ -182,6 +186,12 @@ func CreateOrUpdateFunction(c echo.Context) error {
182186
log.Printf("Failed creation: %v\n", err)
183187
return c.JSON(http.StatusServiceUnavailable, "")
184188
}
189+
190+
if isUpdate {
191+
// terminate any warm container after the update
192+
node.ShutdownWarmContainersFor(&f)
193+
}
194+
185195
response := struct{ Created string }{f.Name}
186196
return c.JSON(http.StatusOK, response)
187197
}

0 commit comments

Comments
 (0)