-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve containers stopping performance by handling SIGTERM
- Loading branch information
Showing
4 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import signal | ||
import sys | ||
import http.server | ||
import socketserver | ||
|
||
PORT = 8000 | ||
|
||
Handler = http.server.SimpleHTTPRequestHandler | ||
|
||
|
||
def signal_handler(sig, frame): | ||
sys.exit(0) | ||
|
||
signal.signal(signal.SIGTERM, signal_handler) | ||
|
||
with socketserver.TCPServer(("", PORT), Handler) as httpd: | ||
print("serving at port", PORT) | ||
httpd.serve_forever() |