Comments (12)
Hi thanks for the question. You get a graceful shutdown period built-in. This gives any HTTP requests a grace period to shut down (you should be able to read about this in the readme)
The period is connected to write_timeout
which I see you may not be specifying correctly at present. A Golang duration is needed i.e. 20s
.
from of-watchdog.
Derek add label: question
from of-watchdog.
What I'm thinking about is a hook whenever a container is taken out of commission (e.g. scale to 0, function removed, etc.). Having a warm JVM means that collecting/releasing resources on each invocation seems a bit silly, so it would be nice to know when the resources MUST be released.
from of-watchdog.
Are you saying it does indeed forward SIGTERM to the fprocess
?
from of-watchdog.
Hi @hejfelix I would be curious as to what Lambda, Google Functions or Azure Functions do in this scenario. If they do pass on SIGTERM then we should investigate it.
Alex
from of-watchdog.
Kubernetes has a rather complicated shutdown procedure regarding health-checks which does not make things easy. cc @LucasRoesler @stefanprodan
from of-watchdog.
My experience with AWS Lambda was that there was no shutdown hook. This essentially meant that I wasted a lot of time acquiring and releasing resources on every invocation. This defeats the purpose of having a warm function.
from of-watchdog.
There are a couple of things that happen during shutdown in a k8s pod
- the Pod is marked as terminated/deleted, this also removes it from various Endpoints and Services in k8s
- the
preStopHook
is executed, this allows the Pod to respond to and customize the stop behavior. But ... this is not something we support configuration of SIGTERM
is sent to the Pod- when the grace period expires,
SIGKILL
is sent. The grace period defaults to 30 seconds and can be customized on the Pod spec viaterminationGracePeriodSeconds
By far the simplest thing we could do is to listen for and send the SIGTERM
to the child process. Which should already be happening (this is the relevant chunk of code that sends the TERM
to the fprocess
in http
mode)
In short, a quick review of the code looks like it is trying to send the TERM signal to the fprocess
, in this case the JVM.
from of-watchdog.
Interesting -- I am running on docker swarm in all my tests so far. Is that supposed to behave the same way? I guess I'm struggling to find a way to verify that my shutdown hook is run since nothing appears in docker service logs after node is taken down. Any ideas?
from of-watchdog.
Probably the simplest way to verify it is to send a message somewhere, e.g. to RequestBin . If you are certain that your shutdown hook runs on SIGTERM and If you don't get a message, then that means you didn't get a SIGTERM
from of-watchdog.
Right, so I'm not getting any shutdown hook. This is my scala code:
Runtime.getRuntime().addShutdownHook(new Thread(){
override def run(): Unit = Source.fromURL(s"http://requestbin.fullcontact.com/wrh63owr/SHUTDOWN_HOOK_SUCK_IT_LAMBDA_${Random.nextInt}").toList
} )
If I run this line e.g. in the REPL, it works:
Source.fromURL(s"http://requestbin.fullcontact.com/wrh63owr/SHUTDOWN_HOOK_SUCK_IT_LAMBDA_${Random.nextInt}").toList
from of-watchdog.
Im starting to believe the problem occurs because my web framework is not reacting to sigterm. Will investigate now and return.
from of-watchdog.
Related Issues (20)
- of-watchdog always uses Transfer-Encoding: chunked despite having a valid and accurate Content-Length available HOT 6
- Documentation - missing 'mode' option description HOT 1
- Documentation - missing mode parameter HOT 2
- Wrong implementation of mode serializing HOT 5
- Got Error "Error scanning stdout: bufio.Scanner: token too long" HOT 1
- Outdated link to Classic Watchdog
- Custom HTTP probes create too much noise in logging
- When prefix_logs="false" is set, % signs logged by the function are interpreted as fmt.Printf verbs HOT 3
- Use of-watchdog for Docker template running a C/C++ function HOT 3
- Upstream HTTP killed due to exec_timeout: 10m0s, but it's after a minute HOT 4
- panic due to SIGSEGV while killing function process in streaming mode HOT 1
- Update GitHub Actions and Dockerfile to use Go 1.18
- Function readiness check HOT 1
- Log "Limited" appearing at the rate of a readiness check
- function custom readiness checking not working as documented HOT 2
- Support request (need more info) HOT 6
- Requesting alternative to setting maximum buffer size HOT 6
- where is of-watchdog image on docker hub? HOT 1
- Hiding URL parameters in watchdog logs HOT 3
- problem with the 0.9.13 arm64 image HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from of-watchdog.